Reputation: 33
I don't set the event signaled, but the WaitForSingleObject always returned. I create a event in the main thread.
g_hHeartMonitorEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
Then in another thread, I use WaitForSingleObject to wait the event signaled.
`
while(true)
{
DWORD dwResult = WaitForSingleObject(lpThis->g_hHeartMonitorEvent, 90 * 1000);
if (WAIT_OBJECT_0 == dwResult)
{
LogWriteEx("WaitForSingleObject:dwResult = WAIT_OBJECT_0");
continue;
}
}
`
I find that WaitForSingleObject always returns WAIT_OBJECT_0. The setevent only is called in one place. The machine has a single-core CPU.
Upvotes: 1
Views: 671
Reputation: 33
It will occur if the handle of event has been close by some unknown reason.
Upvotes: 0