Export (0) Print
Expand All

EventWaitHandle.SetAccessControl Method

Sets the access control security for a named system event.

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

member SetAccessControl : 
        eventSecurity:EventWaitHandleSecurity -> unit

Parameters

eventSecurity
Type: System.Security.AccessControl.EventWaitHandleSecurity

An EventWaitHandleSecurity object that represents the access control security to be applied to the named system event.

ExceptionCondition
ArgumentNullException

eventSecurity is a null reference (Nothing in Visual Basic).

UnauthorizedAccessException

The user does not have EventWaitHandleRights.ChangePermissions.

-or-

The event was not opened with EventWaitHandleRights.ChangePermissions.

SystemException

The current EventWaitHandle object does not represent a named system event.

ObjectDisposedException

The Close method was previously called on this System.Threading.EventWaitHandle.

The user must have EventWaitHandleRights.ChangePermissions rights to call this method, and the event must have been opened with the EventWaitHandleRights.ChangePermissions flag.

The following code example demonstrates the cross-process behavior of a named system event with access control security. The example uses the OpenExisting(String) method overload to test for the existence of a named event.

If the event does not exist, it is created with initial ownership and access control security that denies the current user the right to use the event, but grants the right to read and change permissions on the event.

If you run the compiled example from two command windows, the second copy will throw an access violation exception on the call to OpenExisting(String). The exception is caught, and the example uses the OpenExisting(String, EventWaitHandleRights) method overload to wait on the event with the rights needed to read and change the permissions.

After the permissions are changed, using the SetAccessControl method, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions.

No code example is currently available or this language may not be supported.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

Show:
© 2014 Microsoft