Check AutoResetEvent Status

Can I check how the AutoResetEvent object was actually processed? Is it fired by a timeout or by calling Set () from another method?

Here is my code.

 private AutoResetEvent autoResetEvent = new AutoResetEvent(false); private int timeout = 30000; public void SyncMethod() { // some code before autoResetEvent.WaitOne(timeout); // if autoResetEvent called by timeout then { do some stuff } // some code after } public void AsyncMethod() { // some code before // ok I am done autoResetEvent.Set(); } 
+8
multithreading autoresetevent
source share
2 answers

WaitHandle :: WaitOne Method (Int32)

Return Value Type: System :: Boolean

true if the current instance is receiving a signal; otherwise false.

So, after a timeout, false is returned.

+12
source share

Yes, check the return value

true if the current instance is receiving a signal; otherwise false.

http://msdn.microsoft.com/en-us/library/cc189907

+2
source share

All Articles