.NET - ManualResetEvent.Reset thread blocking

604 Views Asked by At

According to MSDN, the purpose of ManualResetEvent's Reset() method is -

Sets the state of the event to nonsignaled, causing threads to block.

What thread(s) does it block ? The calling thread or the current one or any other ?

Thanks in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

It blocks the threads calling WaitOne() on the wait handle (the ManualResetEvent)

0
On

A ManualResetEvent is class that you can use to synchronize threads. If you wanted one thread to wait for another to finish for example, you can have the the thread you want to finish first call Reset and the second call WaitOne. WaitOne will block the second thread. When the first thread finishes, you will want to call Set which will cause the blocking WaitOne on the second thread to return hence allowing the second thread to finish.