|
-
November 2nd, 2006, 07:58 PM
#4
Re: Proper way to wait for a thread to return.
When I say event, I mean the event created/opened by CreateEvent() and
OpenEvent(), not a GUI event. Which is what you mean by event ?
Don't use Sleep() because you're never guaranteed that the thread won't
resume earlier than you want; too high a wait period will slow the program
down.
Main Thread
1) Create an event handle.
2) Something happens that needs a response
3) Call PulseEvent()
Thread 2
1) WaitForSingleObject on the event handle. CreateEvent() on second event
2) Wakes up after PulseEvent()
3) Processes whatever.
4) Calls PulseEvent on second event
Thread 3
1) WaitForSingleObject on second event handle
2) Processes whatever
Done
Is that how the program is supposed to act ?
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
|