In one of my class i’m launching a thread using the following method:
HANDLE hThread;
unsigned threadID;
hThread = (HANDLE)_beginthreadex( NULL, 0, &myThread, NULL, 0, &threadID );
And from this thread I would like to call a method that has to be called from the main thread (the method is interacting with the UI) but I really don’t know how to do it since the main thread can’t wait until “myThread” notifies it.
I have seen a lot of
while(true){
//wait something from myThread
}
But I can’t wait this way!
Any ideas?
Since your main thread is UI, you can send a message to it.
Your UI message loop should process the message:
And in your worker thread, send UI a message