I have a main thread and a worker thread. The main thread has called
CreateEvent() to create a handle that I want to signal once something
happens in the worker thread.
Am I correct in saying that it is safe to, and in fact I must, duplicate
that handle for the worker thread and use the duplicate to call SetEvent()
from the worker thread? If not (i.e., if I try to call SetEvent() on the
original handle), I would cause a crash or violation of some sort?
Lifetime of app / handle usage:
- Main thread creates 'handle' then spawns worker thread
...
- Calling code calls a routine via main thread
- Main thread waits for event ('handle') to be signalled
...
- Worker thread creates 'duplicate_handle'
- Worker thread calls SetEvent() on duplicate
- Worker thread deletes duplicate (closes)
...
- Main thread stops waiting due to signal and resets event
- Returns to calling code
...
- Main thread stops worker thread (signals it to end itself and
waits) then deletes event (closes handle).
Is the above correct procedure? I'm only just learning how to use events and
threads properly.
--
Jason Teagle
[EMAIL PROTECTED]
_______________________________________________
msvc mailing list
[email protected]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.