I just have a global CEvent object etc. I could dig out the code. As to whether it is correct procedure... Another story..
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Jason Teagle > Sent: 25 January 2005 13:58 > To: MSVC At BeginThread > Subject: [msvc] Handles Across Threads > > > 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 > msvc@beginthread.com > See > http://beginthread.com/mailman/listinfo/msvc_beginthread.com > for subscription changes, and list archive. > > > This message has been scanned for viruses by MailControl - > (see http://bluepages.wsatkins.co.uk/?4318150) > This email and any attached files are confidential and copyright protected. If you are not the addressee, any dissemination of this communication is strictly prohibited. Unless otherwise expressly agreed in writing, nothing stated in this communication shall be legally binding. _______________________________________________ msvc mailing list msvc@beginthread.com See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.