ManualResetEvent Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Notifies one or more waiting threads that an event has occurred. This class cannot be inherited.
System.Threading::WaitHandle
System.Threading::EventWaitHandle
System.Threading::ManualResetEvent
Assembly: mscorlib (in mscorlib.dll)
The ManualResetEvent type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ManualResetEvent | Initializes a new instance of the ManualResetEvent class with a Boolean value that indicates whether to set the initial state to signaled. |
| Name | Description | |
|---|---|---|
![]() | SafeWaitHandle | Gets or sets the native operating-system handle. (Inherited from WaitHandle.) |
| Name | Description | |
|---|---|---|
![]() | Close | When overridden in a derived class, releases all resources held by the current WaitHandle. (Inherited from WaitHandle.) |
![]() | Dispose() | Releases all resources used by the current instance of the WaitHandle class. (Inherited from WaitHandle.) |
![]() | Dispose(Boolean) | When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources. (Inherited from WaitHandle.) |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Reset | Sets the state of the event to non-signaled, which causes threads to block. (Inherited from EventWaitHandle.) |
![]() | Set | Sets the state of the event to signaled, which allows one or more waiting threads to proceed. (Inherited from EventWaitHandle.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | WaitOne() | Blocks the current thread until the current WaitHandle receives a signal. (Inherited from WaitHandle.) |
![]() | WaitOne(Int32) | Blocks the current thread until the current WaitHandle receives a signal, using 32-bit signed integer to specify the time interval. (Inherited from WaitHandle.) |
![]() | WaitOne(TimeSpan) | Blocks the current thread until the current instance receives a signal, using a TimeSpan to specify the time interval. (Inherited from WaitHandle.) |
ManualResetEvent enables threads to communicate with each other by signaling. Typically, this communication concerns a task that one thread must complete before other threads can proceed.
When a thread begins an activity that must complete before other threads proceed, it calls the Reset method to put ManualResetEvent in the non-signaled state. This thread can be thought of as controlling the ManualResetEvent. Threads that call the WaitOne method on the ManualResetEvent will block, waiting for the signal. When the controlling thread completes the activity, it calls the Set method 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 staticWaitAll and WaitAny methods.
For more information about thread synchronization mechanisms, see EventWaitHandle, AutoResetEvent, and ManualResetEvent in the conceptual documentation.
The following example demonstrates how to use ManualResetEvent with AutoResetEvent to synchronize the activities of multiple threads, including the UI thread.
The ManualResetEvent is used to release several threads at the same time, in step 2 and step 5b.
For a more detailed description of this example, see the comments in the code or the full introduction to the example that is provided for the EventWaitHandle class.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |



Note: