Skip to content

Instantly share code, notes, and snippets.

@thinkhy
Created March 18, 2011 06:46
Show Gist options
  • Save thinkhy/875701 to your computer and use it in GitHub Desktop.
Save thinkhy/875701 to your computer and use it in GitHub Desktop.
演示MsgWaitForMultipleObjects的用法
// 等待打包工具初始化成功,等待时间为10秒
DWORD dwWait = WAIT_FAILED;
MSG msg;
do
{
dwWait = MsgWaitForMultipleObjects(
1,
&hEvent,
TRUE,
5000,
QS_POSTMESSAGE);
switch (dwWait)
{
case WAIT_OBJECT_0 + 1:
{
if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
break;
}
case WAIT_OBJECT_0: // 打包工具成功启动
{
::ShowWindow(hwnd, SW_HIDE);
break;
}
default:
{
CloseHandle(hEvent);
CloseHandle(hPipe);
AfxMessageBox(L"打包工具启动失败", MB_ICONERROR);
return false;
}
}
} while(dwWait != WAIT_OBJECT_0);
@thinkhy
Copy link
Author

thinkhy commented Mar 18, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment