[英]WaitForSingleObject always return WAIT_OBJECT_0
I don't set the event signaled, but the WaitForSingleObject always returned.我没有设置事件信号,但 WaitForSingleObject 总是返回。 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.然后在另一个线程中,我使用 WaitForSingleObject 来等待发出信号的事件。
` `
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.我发现 WaitForSingleObject 总是返回 WAIT_OBJECT_0。 The setevent only is called in one place.
setevent 只在一处调用。 The machine has a single-core CPU.
该机器具有单核CPU。
如果由于某种未知原因关闭了事件句柄,则会发生这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.