WaitForSingleObject
while (WaitForSingleObject(g_pMainFrame->m_hEventStopCheckNet,0) == WAIT_TIMEOUT)//为0,对象没有被触发信号,函数不会进入一个等待状态,它总是立即返回(一直循环)
{
DWORD dwFlags = 0;
bool bNetConnected = ::IsNetworkAlive(&dwFlags);
if (bNetConnected != g_pMainFrame->IsNetConnected())
{
g_pMainFrame->SetNetConnected(bNetConnected);
g_pMainFrame->SendNotify(NOTIFY_NET_STATUS_CHANGED);
}
if (WaitForSingleObject(g_pMainFrame->m_hEventStopCheckNet,1000) != WAIT_TIMEOUT)//函数处于等待状态直到hHandle 标记的对象被触发(即SetEvent),或者时间到了(等1000毫秒,没有触发信号,返回值为WAIT_TIMEOUT)
{
break;
}
}