How to find what state ManualResetEvent is in?

Perform a WaitOne on the event with a timeout value of zero.

It will return true if the event is set, or false if the timeout occurs. In other words, true -> event is set, false -> event is not set.


You can make function calls in the Debugger Watch window. Add a call to mreVariable.WaitOne(0) in the Watch window and see what it evaluates to. Note: You should not use this for AutoResetEvents since that could change the actual state.


Here is working code:

private ManualResetEvent pause = new ManualResetEvent(false);
pause.WaitOne(); // caller thread pauses
pause.Set();    // another thread releases paused thread

// Check pause state
public bool IsPaused { get { return !pause.WaitOne(0); } }