ManualResetEvent Class

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

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

No code example is currently available or this language may not be supported.

The ManualResetEvent type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ManualResetEventInitializes a new instance of the ManualResetEvent class with a Boolean value that indicates whether to set the initial state to signaled.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360SafeWaitHandleGets or sets the native operating-system handle. (Inherited from WaitHandle.)
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360CloseWhen overridden in a derived class, releases all resources held by the current WaitHandle. (Inherited from WaitHandle.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360Dispose()Releases all resources used by the current instance of the WaitHandle class. (Inherited from WaitHandle.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360Dispose(Boolean)When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources. (Inherited from WaitHandle.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360Equals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360FinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ResetSets the state of the event to non-signaled, which causes threads to block. (Inherited from EventWaitHandle.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360SetSets the state of the event to signaled, which allows one or more waiting threads to proceed. (Inherited from EventWaitHandle.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360WaitOne()Blocks the current thread until the current WaitHandle receives a signal. (Inherited from WaitHandle.)

In Silverlight for Windows Phone, this member is overridden by WaitOne().


In XNA Framework, this member is overridden by WaitOne().
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360WaitOne(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.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360WaitOne(TimeSpan)Blocks the current thread until the current instance receives a signal, using a TimeSpan to specify the time interval. (Inherited from WaitHandle.)
Top

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 static WaitAll 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.

No code example is currently available or this language may not be supported.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

This class is thread safe.

Community Additions

ADD
Show: