09-02-2008, 02:28 PM
Thumbs Must Hurt
Join Date: Apr 2008
Carrier: US Cellular
Post Thanks: 0
Thanked 0 Times in 0 Posts
| | Thread synchronization
Please Login to Remove!
Within my main thread I have a timer which fires multiple times per second, and invalidates the screen if there are active drawing jobs. I have a worker thread which spawns the drawing jobs at various times, then exits.
I want the worker thread to trigger an event in the main thread upon completion. Within Windows I would simply SendMessage something to my main thread's message handler, or I would have a loop in my main thread which checks for the desired event (WaitForSingleObject) while pumping messages to keep my UI alive (PeekMessage / DispatchMessage).
Obviously I can have my timer event check for something I set in my worker thread, but I don't want to go that route unless I have no other choice.
Is there a way to have the main thread wait for some event or other construct (mutex, etc) while still processing UI events? Or is there a way to trigger an event from a worker thread? I don't think invokeLater will work, because that is just single threaded, and my worker thread won't run concurrent to my timer events.