GetMessage with a timeout
- by qdii
I have an application which second thread calls GetMessage() in a loop. At some point the first thread realizes that the user wants to quit the application and notifies the second thread that he should terminate. As the first thread is stuck on GetMessage(), the program never quits. Is there a way to wait for messages with a timeout?
I’m open to other ideas too.
EDIT: (additional explanations)
The second thread runs that snippet of code:
while ( !m_quit && GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
The first thread sets m_quit to true.