NumEvents = 1;
while (!m_bTerminated) {
// Wait for an event (or a queued callback function) to wake
// us up. This is an alertable wait state (fAlertable == TRUE).
WaitStatus = MsgWaitForMultipleObjectsEx(
NumEvents, hEvents, INFINITE, QS_ALLINPUT, 0 );
if ( WaitStatus == WSA_WAIT_EVENT_0 + NumEvents ) {
// This is message
while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) {
case WM_DEFINE1: {
ON_MsgDefine1(msg);
break;
}
case WM_DEFINE2: {
ON_MsgDefine2(msg);
break;
}}
}
}
}
switch (WaitStatus)
{
case WAIT_TIMEOUT:
// A fatal error. Pop up a message box and break out of
// the while loop to end the thread.
break;
case WAIT_OBJECT_0:
// system is going down
m_bTerminated = true;
break;
}
}//while(Forever)
SetEvent(hStopThreadEvent);
return true;
}