HANDLE hTshorthread1[3];
hTshorthread1[0] = xxxxxxx;
hTshorthread1[1] = xxxxxxx;
hTshorthread1[2] = xxxxxxx;
BOOL bWait = TRUE;
while (bWait)
{
DWORD dwEvt = MsgWaitForMultipleObjects(1,hTshorthread1,FALSE,INFINITE,QS_ALLINPUT);
switch(dwEvt)
{
case WAIT_OBJECT_0:
bWait = false;
break;
case WAIT_OBJECT_0 + 1:
{
MSG msg;
while(::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (WM_CLOSE == msg.message || WM_QUIT == msg.message)
{
bWait = false;
break;
}
else
{
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
break;
}
default: // WAIT_TIMEOUT WAIT_FAILED
bWait = false;
break;
}
} // end while
如果只是等待单个线程时;如
HANDLE hTshorthread1;
hTshorthread1 = xxxxxxx;
要加取地址符号,如
DWORD dwEvt = MsgWaitForMultipleObjects(1,&hTshorthread1,FALSE,INFINITE,QS_ALLINPUT);