System.Threading.Semaphore.Release Method

Exits the semaphore a specified number of times and returns the previous count.

Syntax

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

Parameters

releaseCount
The number of times to exit the semaphore.

Returns

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

Remarks

If a thread has entered the semaphore multiple times, this method overload allows the entire semaphore count to be restored with one call.

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