If I create an event using CreateEvent in Windows, how can I check if that event is signaled or not using the debugger in Visual Studio? CreateEvent returns back a Handle, which doesn't give me access to much information. Before I call WaitForSingleObject(...), I want to check to see if the event is signaled before I step into the function.
If the event is signaled and you use WaitForSingleObject(), it will return immediately. Also, you can call WaitForSingleObject() with a wait time of 0 to determine if it is signaled or not. However, that should not be necessary -- set the initial state in the CreateEvent() call (what has elapsed so far is unclear in your question).
Thanks Kris. I didn't want to add any extra code. I'm trying to synchronize 2 threads by using events. I have a WaitForSingleObject( eventHandle, INFINITE ) in the 2nd thread and have a placed a breakpoint there. Before I invoke that instruction, I was wondering if I could mnaually check (through some window or command prompt) if the the eventHandle is signaled or not.
You can use the Process Explorer tool (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) to manually check the event outside of the debugger. It helps if the event is named, so that you can find it easier.
Use the handle command. Here is a sample
The following command displays detailed information about handle 0x8.
0:000> !handle 8 f
Handle 8 Type Event Attributes 0 GrantedAccess 0x100003: Synch QueryState,ModifyState HandleCount 2 PointerCount 3 Name Object Specific Information Event Type Auto Reset Event is Waiting