EventWaitHandle.SetAccessControl Method (EventWaitHandleSecurity)

 

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.

Exception Condition
ArgumentNullException

eventSecurity is null.

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
Available since 2.0
Return to top
Show: