System.Threading.Semaphore.Release Method

Exits the semaphore and returns the previous count.

Syntax

[System.Runtime.ConstrainedExecution.PrePrepareMethod]
[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public int Release ()

Returns

The count on the semaphore before the erload:System.Threading.Semaphore.Release method was called.

Remarks

Threads typically use the erload:System.Threading.WaitHandle.WaitOne method to enter the semaphore, and they typically use this method overload to exit.

If a System.Threading.SemaphoreFullException is thrown by the erload:System.Threading.Semaphore.Release method, it does not necessarily indicate a problem with the calling thread. A programming error in another thread might have caused that thread to exit the semaphore more times than it entered.

If the current System.Threading.Semaphore object represents a named system semaphore, the user must have System.Security.AccessControl.SemaphoreRights.Modify rights and the semaphore must have been opened with System.Security.AccessControl.SemaphoreRights.Modify rights.

Requirements

Namespace: System.Threading
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0