Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check event object's state without actually changing it?

Tags:

winapi

The problem is that the WaitForMultipleObjects(Ex) returns just smallest index of all the signalled objects in an array. I would like to know what exactly event objects (created using CreateEvent) are in signalled (or non-signalled) state. I think it is not possible but decided to ask just to make sure I'm not missing anything =)

like image 918
Abdulla Alhazred Avatar asked Mar 05 '12 23:03

Abdulla Alhazred


1 Answers

For each object whose state you want to test, call WaitForSingleObject with a timeout of zero. If it returns WAIT_OBJECT_0, then the object is signaled. Otherwise, it's not.

Unless you have an auto-reset event, waiting for an object to become signaled does not alter its state.

Keep in mind that the state you detect with WaitForSingleObject isn't necessarily the same state the object had when WaitForMultipleObjects returned. More objects might have become signaled in the meantime, and other objects might have become non-signaled.

like image 119
Rob Kennedy Avatar answered Oct 21 '22 09:10

Rob Kennedy