Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

EventWaitHandle::TryOpenExisting Method (String, EventWaitHandle%)

.NET Framework 4.5

Opens the specified named synchronization event, if it already exists, and returns a value that indicates whether the operation succeeded.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)
static bool TryOpenExisting(
	String^ name, 
	[OutAttribute] EventWaitHandle^% result


Type: System::String

The name of the system synchronization event to open.

Type: System.Threading::EventWaitHandle%

When this method returns, contains a EventWaitHandle object that represents the named synchronization event if the call succeeded, or nullptr if the call failed. This parameter is treated as uninitialized.

Return Value

Type: System::Boolean
true if the named synchronization event was opened successfully; otherwise, false.

name is an empty string.


name is longer than 260 characters.


name is nullptr.


A Win32 error occurred.


The named event exists, but the user does not have the desired security access.

If the named synchronization event does not exist, this method does not create it. To create the system event when it does not already exist, use one of the EventWaitHandle constructors that has a name parameter.

If you are uncertain whether a named synchronization event exists, use this method overload instead of the OpenExisting(String) method overload, which throws an exception if the synchronization event does not exist.

This method overload is equivalent to calling the TryOpenExisting(String, EventWaitHandleRights, EventWaitHandle%) method overload and specifying EventWaitHandleRights::Synchronize and EventWaitHandleRights::Modify rights, combined by using the bitwise OR operation. Specifying the EventWaitHandleRights::Synchronize flag allows a thread to wait on the named system event, and specifying the EventWaitHandleRights::Modify flag allows a thread to call the Set and Reset methods.

Multiple calls to this method that use the same value for name do not necessarily return the same EventWaitHandle object, even though the objects that are returned represent the same named system event.

.NET Framework

Supported in: 4.5.1, 4.5

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
  • SecurityCriticalAttribute 

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

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.