|
-
May 27th, 1999, 05:16 AM
#1
Posting close message to child thread from primary thread
I tried to post WM_CLOSE message to child thread from primary thread using Postthreadmessage in a while loop and i am ensuring that child thread is killed using Getexitcodethread(this also in while loop).The problem is it works fine in Debug Mode but it fails in RELEASE mode why?.It will not come out of while loop of GetExitCodeThread.Can u correct my logic
Nag
-
May 27th, 1999, 07:36 PM
#2
Re: Posting close message to child thread from primary thread
Hi,
GetExitCodeThread will just return the exit code of the thread.At that point there is no surity that the child thread is dead.So after u post the quit message to the child thread,u can wait on it and when the wait returns ,u can be sure that the thread is no more.
sample code:
DWORD PrimaryThread(LPVOID)
{
HANDLE hChildThread;
DWORD dwChildThreadId;
while(1)
{
hChildThread=CreateThread(NULL,0,ChildThread,0,0,&dwChildThreadId)
Do Stuff
PostThreadMessage (dwChildThreadId,WM_QUIT,0,0);
WaitForSingleObject(hChildThread,INFINITE);
now the child thread is dead for sure
}
}
DWORD ChildThread(LPVOID)
{
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|