Semaphore.SetAccessControl(SemaphoreSecurity) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the access control security for a named system semaphore.
public:
void SetAccessControl(System::Security::AccessControl::SemaphoreSecurity ^ semaphoreSecurity);
public void SetAccessControl(System.Security.AccessControl.SemaphoreSecurity semaphoreSecurity);
member this.SetAccessControl : System.Security.AccessControl.SemaphoreSecurity -> unit
Public Sub SetAccessControl (semaphoreSecurity As SemaphoreSecurity)
Parameters
- semaphoreSecurity
- SemaphoreSecurity
A SemaphoreSecurity object that represents the access control security to be applied to the named system semaphore.
Exceptions
semaphoreSecurity is null.
The user does not have ChangePermissions rights.
-or-
The semaphore was not opened with ChangePermissions rights.
The current Semaphore object does not represent a named system semaphore.
Examples
The following code example demonstrates the cross-process behavior of a named semaphore with access control security. The example uses the OpenExisting(String) method overload to test for the existence of a named semaphore.
If the semaphore does not exist, it is created with a maximum count of two and with access control security that denies the current user the right to use the semaphore but grants the right to read and change permissions on the semaphore.
If you run the compiled example from two command windows, the second copy will throw an access violation exception on the call to the