Permalink
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (30 sloc) 2.57 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
ManualResetEvent and ManualResetEventSlim
03/30/2017
.net
dotnet-standard
article
threading [.NET Framework], ManualResetEvent class
ManualResetEvent class, about ManualResetEvent class
465fdcf9-ba24-4d8d-a43f-d983b7cb0cc6
17
rpetrusha
ronpet
wpickett

ManualResetEvent and ManualResetEventSlim

The xref:System.Threading.ManualResetEvent?displayProperty=nameWithType class represents a local wait handle event that must be reset manually after it is signaled. This class represents a special case of its base class, xref:System.Threading.EventWaitHandle?displayProperty=nameWithType. See the EventWaitHandle conceptual documentation for the use and features of manual reset events.

A xref:System.Threading.ManualResetEvent object remains signaled until its xref:System.Threading.EventWaitHandle.Reset%2A?displayProperty=nameWithType method is called. Any number of waiting threads, or threads that wait on the event after it has been signaled, can be released while the object's state is signaled. xref:System.Threading.ManualResetEvent corresponds to a Win32 CreateEvent call, specifying true for the bManualReset argument.

In the [!INCLUDEnet_v40_long], you can use the xref:System.Threading.ManualResetEventSlim?displayProperty=nameWithType class for better performance when wait times are expected to be very short, and when the event does not cross a process boundary. xref:System.Threading.ManualResetEventSlim uses busy spinning for a short time while it waits for the event to become signaled. When wait times are short, spinning can be much less expensive than waiting by using wait handles. However, if the event does not become signaled within a certain period of time, xref:System.Threading.ManualResetEventSlim resorts to a regular event handle wait.

See Also

Threading
Threading Objects and Features
Wait Handles
AutoResetEvent
SpinWait
Semaphore and SemaphoreSlim