I’ve got an event loop that’s waiting on several auto-reset events.
The events were all initialized into array eventHandles_ with CreateEvent(NULL, false, false, NULL).
while (true)
{
DWORD waitResult = WaitForMultipleObjects(3, eventHandles_, false, INFINITE);
switch (waitResult)
{
case WAIT_OBJECT_0 + 0:
//handle event...
case WAIT_OBJECT_0 + 1:
//handle event...
case WAIT_OBJECT_0 + 2:
//handle event...
}
}
My question: if event 1 and 2 occur simultaneously, the loop will process WAIT_OBJECT_0 + 1 because it’s first. But will event 2 remain signaled when the loop comes around again? Or does it get reset automatically?
“…modification occurs only for the object or objects whose signaled state caused the function to return…”
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687025(v=vs.85).aspx
And from the mouth of one Raymond Chen: