+ MSG peekMsg;
+ // Check if a new message has really arrived.
+ // MsgWaitForMultipleObjects can indicate that a message
+ // is ready for processing, but this message may be sucked
+ // up by GetMessage and then GetMessage will hang and not
+ // allow us to process the actual thread exit event.
+ if (::PeekMessage(&peekMsg, (HWND) NULL, 0, 0, PM_NOREMOVE))
+ {
+ // new message arrived, process it
+ if ( !wxTheApp->DoMessage() )
+ {
+ // WM_QUIT received: kill the thread
+ Kill();
+
+ return wxTHREAD_KILLED;
+ }
+ }