EventWaitHandle Constructor (Boolean, EventResetMode, String, Boolean)

 

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, the name of a system synchronization event, and a Boolean variable whose value after the call indicates whether the named system event was created.

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

[SecurityCriticalAttribute]
public EventWaitHandle(
	bool initialState,
	EventResetMode mode,
	string name,
	out bool createdNew
)

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.

createdNew
Type: System.Boolean

When this method returns, contains true if a local event was created (that is, if name is null or an empty string) or if the specified named system event was created; false if the specified named system event already existed. This parameter is passed uninitialized.

Exception Condition
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 a system event with the name specified for the name parameter already exists, the initialState parameter is ignored. After calling this constructor, use the value in the variable specified for the ref parameter (ByRef parameter in Visual Basic)createdNew to determine whether the named system event already existed or was created.

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.

SecurityCriticalAttribute

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

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: