Permalink
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (42 sloc) 3.38 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
EventWaitHandle, AutoResetEvent, CountdownEvent, ManualResetEvent
03/30/2017
.net
dotnet-standard
article
wait handles
threading [.NET Framework], EventWaitHandle class
event wait handles [.NET Framework]
cd94fc34-ac15-427f-b723-a1240a4fab7d
12
rpetrusha
ronpet
wpickett

EventWaitHandle, AutoResetEvent, CountdownEvent, ManualResetEvent

Event wait handles allow threads to synchronize activities by signaling each other and by waiting on each other's signals. These synchronization events are based on Win32 wait handles and can be divided into two types: those that reset automatically when signaled and those that are reset manually.

Event wait handles are useful in many of the same synchronization scenarios as the xref:System.Threading.Monitor class. Event wait handles are often easier to use than the xref:System.Threading.Monitor.Wait%2A?displayProperty=nameWithType and xref:System.Threading.Monitor.Pulse%2A?displayProperty=nameWithType methods, and they offer more control over signaling. Named event wait handles can also be used to synchronize activities across application domains and processes, whereas monitors are local to an application domain.

In This Section

EventWaitHandle
The xref:System.Threading.EventWaitHandle class can represent either automatic or manual reset events and either local events or named system events.

AutoResetEvent
The xref:System.Threading.AutoResetEvent class derives from xref:System.Threading.EventWaitHandle and represents a local event that resets automatically.

ManualResetEvent and ManualResetEventSlim
The xref:System.Threading.ManualResetEvent class derives from xref:System.Threading.EventWaitHandle and represents a local event that must be reset manually. The xref:System.Threading.ManualResetEventSlim class is a lightweight, faster version that can be used for events within the same process.

CountdownEvent
The xref:System.Threading.CountdownEvent class provides a simplified way to implement fork/join parallelism patterns in code that uses wait handles.

Related Sections

Wait Handles
The xref:System.Threading.WaitHandle class is the base class for the xref:System.Threading.EventWaitHandle, xref:System.Threading.Semaphore, and xref:System.Threading.Mutex classes. It contains static methods such as xref:System.Threading.WaitHandle.SignalAndWait%2A and xref:System.Threading.WaitHandle.WaitAll%2A that are useful when working with all types of wait handles.

See Also

xref:System.Threading.EventWaitHandle
xref:System.Threading.WaitHandle
xref:System.Threading.AutoResetEvent
xref:System.Threading.ManualResetEvent
Threading Objects and Features
Managed Threading Basics