I have a MFC-C++ application where at least two threads are running "MainFrame" (=GUI thread) and a "Solver" thread.
At one point the second thread (Solver) initiate a change in the model which the GUI thread should execute by a PostMessage(...)
. To be safe I want to wait that message was proceeded to continue in the second thread.
By using a SendMessage(...)
the Solver thread waits for the message to be executed but in this way we bypass the message queue which shouldn't be the goal.
My question: How can I properly and clean check/trigger that my message was proceed before I continue?
- Did we need to check every 'x' seconds the status of the main thread message queue by
GetQueueStatus(...)
? - Is there a way to have the main thread send back a "success event" to the other thread? And that the second one waits to have an event back?
- Did boost provide an easy solution for this kind of problems?
- Was there already a similar question which i didn't found? (sorry)
My function:
void PostSequencerMessageToGUI(ESequencerSignal signal, CSchedulerStep * step)
{
CMainFrame *mainFrame = theApp.GetMainFrame();
assert(mainFrame);
if (!mainFrame)
return;
mainFrame->PostMessage(WM_SEQUENCER_SIGNAL, signal, reinterpret_cast<LPARAM>(step));
// mainFrame->SendMessage(WM_SEQUENCER_SIGNAL, signal, reinterpret_cast<LPARAM>(step));
// Message was posted, now wait for event back to continue procedure
// ... but how? ...and when to cancel ? ...
return;
}
PostMessage
with a reply, use SendMessageCallback. – IInspectable