|
-
May 20th, 1999, 06:43 PM
#1
How to kill a thread ?
How do you kill a thread from the main application when the thread is in some sort of blocking call and is not receiving any messages from the system. Is there an easy answer I am missing.
Thanx for your insight.
-
May 20th, 1999, 06:55 PM
#2
Re: How to kill a thread ?
What I usually do is set a global flag (of type BOOL). The thread's main loop checks if the flag is TRUE,
and if so the thread is exited. For example:
BOOL stopthread = FALSE;
UINT ThreadFunction(LPVOID lp)
{
while (1)
{
if (stopthread) return 0;
}
}
Then anywhere in your code you could set 'stopthread' to TRUE to stop the thread.
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
|