ManualResetEvent Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Notifies one or more waiting threads that an event has occurred. This class cannot be inherited.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public sealed class ManualResetEvent : WaitHandle

The ManualResetEvent type exposes the following members.

  NameDescription
Public methodManualResetEventInitializes a new instance of the ManualResetEvent class with a Boolean value indicating whether to set the initial state to signaled.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodResetSets the state of the event to nonsignaled, which causes threads to block.
Public methodSetSets the state of the event to signaled, which allows one or more waiting threads to proceed.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWaitOne()()()()Blocks the current thread until the current WaitHandle receives a signal. (Inherited from WaitHandle.)
Public methodWaitOne(Int32, Boolean)Blocks the current thread until the current WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval and specifying whether to exit the synchronization domain before the wait. (Inherited from WaitHandle.)
Top

NoteNote

Unlike the ManualResetEvent class, the EventWaitHandle class provides access to named system synchronization events.

ManualResetEvent allows threads to communicate with each other by signaling. Typically, this communication concerns a task which one thread must complete before other threads can proceed.

When a thread begins an activity that must complete before other threads proceed, it calls Reset to put ManualResetEvent in the non-signaled state. This thread can be thought of as controlling the ManualResetEvent. Threads that call WaitOne on the ManualResetEvent will block, awaiting the signal. When the controlling thread completes the activity, it calls Set to signal that the waiting threads can proceed. All waiting threads are released.

Once it has been signaled, ManualResetEvent remains signaled until it is manually reset. That is, calls to WaitOne return immediately.

You can control the initial state of a ManualResetEvent by passing a Boolean value to the constructor, true if the initial state is signaled and false otherwise.

ManualResetEvent can also be used with the static WaitAll and WaitAny methods.

This class is thread safe.

Show: