AutoResetEvent Class

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

Notifies a waiting thread that an event has occurred. This class cannot be inherited.

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

public sealed class AutoResetEvent : WaitHandle

The AutoResetEvent type exposes the following members.

Public methodAutoResetEventInitializes a new instance of the AutoResetEvent class with a Boolean value indicating whether to set the initial state to signaled.

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 at most one waiting thread 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.)

AutoResetEvent allows threads to communicate with each other by signaling. Typically, you use this class when threads need exclusive access to a resource.

A thread waits for a signal by calling WaitOne on the AutoResetEvent. If the AutoResetEvent is in the non-signaled state, the thread blocks, waiting for the thread that currently controls the resource to signal that the resource is available by calling Set.

Calling Set signals AutoResetEvent to release a waiting thread. AutoResetEvent remains signaled until a single waiting thread is released, and then automatically returns to the non-signaled state. If no threads are waiting, the state remains signaled indefinitely.

If a thread calls WaitOne while the AutoResetEvent is in the signaled state, the thread does not block. The AutoResetEvent releases the thread immediately and returns to the non-signaled state.

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

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


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

This class is thread safe.