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.
Inheritance Hierarchy
System. . :: . .Object
System. . :: . .MarshalByRefObject
System.Threading. . :: . .WaitHandle
System.Threading..::..ManualResetEvent
Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public NotInheritable Class ManualResetEvent _
Inherits WaitHandle
public sealed class ManualResetEvent : WaitHandle
public ref class ManualResetEvent sealed : public WaitHandle
[<Sealed>]
type ManualResetEvent =
class
inherit WaitHandle
end
public final class ManualResetEvent extends WaitHandle
The ManualResetEvent type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ManualResetEvent | Initializes a new instance of the ManualResetEvent class with a Boolean value indicating whether to set the initial state to signaled. |
Top
Methods
Name | Description | |
---|---|---|
Equals(Object) | Determines whether the specified Object is equal to the current Object. (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.) | |
Reset | Sets the state of the event to nonsignaled, which causes threads to block. | |
Set | Sets the state of the event to signaled, which allows one or more waiting threads to proceed. | |
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, 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
Remarks
Note
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 staticWaitAll and WaitAny methods.
Thread Safety
This class is thread safe.