Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question: When is a CWinThread really done?

3 views
Skip to first unread message

S. Brent Faulkner

unread,
Feb 18, 1997, 3:00:00 AM2/18/97
to

I'm trying to invoke a Win32 function in a CWinThread derived UI thread
when the thread instance is cleaned up. (For those of you who saw an
earlier post of mine I solved my thread initialization problem.)

The problem is:

a) ::CloseDesktop() insists upon no thread currently being assigned to the
desktop I am trying to close.
b) ::SetThreadDesktop() (which I need to call to resolve problem a.)
insists upon the desktop in which the thread currently is assigned to
having no attached windows and no hooks.

I have tried replacing hooking a virtual function (PostAfxEndThread()) into
a replacement for _AfxThreadEntry() in order to provide a "callback"
between the AfxEndThread() call and the _endthreadex() call, but something
still prevents the call to ::SetThreadDesktop() from succeeding. A few
breakpoints placed strategically seem to indicate that the MFC dll still
has some hooks into the thread which don't get cleaned up until the
_endthreadex() call.

Any ideas?

My best guess at the moment is a notification message from the thread to my
application's main thread, which is processed by waiting for the real
termination of the thread and then doing the cleanup from outside the
thread.

Thanks,

--Brent

PS. (Mike Blasczak are you listening? I think you would know...)

------------------------------------------------------------------------
S. Brent Faulkner
br...@golden.net (home)
br...@allross.com (business)


0 new messages