Edit

Share via


SemaphoreSlim.Release Method

Definition

Releases the SemaphoreSlim object.

Overloads

Release()

Releases the SemaphoreSlim object once.

Release(Int32)

Releases the SemaphoreSlim object a specified number of times.

Release()

Source:
SemaphoreSlim.cs
Source:
SemaphoreSlim.cs
Source:
SemaphoreSlim.cs
Source:
SemaphoreSlim.cs

Releases the SemaphoreSlim object once.

public int Release();

Returns

The previous count of the SemaphoreSlim.

Exceptions

The current instance has already been disposed.

The SemaphoreSlim has already reached its maximum size.

Remarks

A call to the Release() method increments the CurrentCount property by one. If the value of the CurrentCount property is zero before this method is called, the method also allows one thread or task blocked by a call to the Wait or WaitAsync method to enter the semaphore.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Release(Int32)

Source:
SemaphoreSlim.cs
Source:
SemaphoreSlim.cs
Source:
SemaphoreSlim.cs
Source:
SemaphoreSlim.cs

Releases the SemaphoreSlim object a specified number of times.

public int Release(int releaseCount);

Parameters

releaseCount
Int32

The number of times to exit the semaphore.

Returns

The previous count of the SemaphoreSlim.

Exceptions

The current instance has already been disposed.

releaseCount is less than 1.

The SemaphoreSlim has already reached its maximum size.

Remarks

A call to the Release(Int32) method increments the CurrentCount property by releaseCount. If the value of the CurrentCount property is zero before this method is called, the method also allows releaseCount threads or tasks blocked by a call to the Wait or WaitAsync method to enter the semaphore.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0