Export (0) Print
Expand All

EventWaitHandle Constructor (Boolean, EventResetMode, String)

Initializes a new instance of the EventWaitHandle class, specifying whether the wait handle is initially signaled if created as a result of this call, whether it resets automatically or manually, and the name of a system synchronization event.

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

public EventWaitHandle(
	bool initialState,
	EventResetMode mode,
	string name
)

Parameters

initialState
Type: System.Boolean

true to set the initial state to signaled if the named event is created as a result of this call; false to set it to nonsignaled.

mode
Type: System.Threading.EventResetMode

One of the EventResetMode values that determines whether the event resets automatically or manually.

name
Type: System.String

The name of a system-wide synchronization event.

ExceptionCondition
IOException

A Win32 error occurred.

UnauthorizedAccessException

The named event exists and has access control security, but the user does not have EventWaitHandleRights.FullControl.

WaitHandleCannotBeOpenedException

The named event cannot be created, perhaps because a wait handle of a different type has the same name.

ArgumentException

name is longer than 260 characters.

If name is null or an empty string, a local EventWaitHandle is created.

If a system event with the name specified for the name parameter already exists, the initialState parameter is ignored.

Important noteImportant

When using this constructor for named system events, specify false for initialState. This constructor provides no way to determine whether a named system event was created, so you cannot make any assumptions about the state of the named event. To determine whether a named event was created, use the EventWaitHandle(Boolean, EventResetMode, String, Boolean) constructor or the EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity) constructor.

If the initial state of the event is nonsignaled, threads that wait on the event will block. If the initial state is signaled, and the ManualReset flag is specified for mode, threads that wait on the event will not block. If the initial state is signaled, and mode is AutoReset, the first thread that waits on the event will be released immediately, after which the event will reset, and subsequent threads will block.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

  • SecurityCriticalAttribute 

    Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Show:
© 2015 Microsoft