<PackageReference Include="Nito.AsyncEx.Coordination" Version="1.0.2" />

Nito.AsyncEx.AsyncSemaphore

public sealed class AsyncSemaphore
An async-compatible semaphore. Alternatively, you could use SemaphoreSlim.
public long CurrentCount { get; }

Gets the number of slots currently available on this semaphore. This member is seldom used; code using this member has a high possibility of race conditions.

public int Id { get; }

Gets a semi-unique identifier for this asynchronous semaphore.

public AsyncSemaphore(long initialCount, IAsyncWaitQueue<object> queue)

Creates a new async-compatible semaphore with the specified initial count.

public AsyncSemaphore(long initialCount)

Creates a new async-compatible semaphore with the specified initial count.

public void Release(long releaseCount)

Releases the semaphore.

public void Release()

Releases the semaphore.

public void Wait(CancellationToken cancellationToken)

Synchronously waits for a slot in the semaphore to be available. This method may block the calling thread.

public void Wait()

Synchronously waits for a slot in the semaphore to be available. This method may block the calling thread.

public Task WaitAsync(CancellationToken cancellationToken)

Asynchronously waits for a slot in the semaphore to be available.

public Task WaitAsync()

Asynchronously waits for a slot in the semaphore to be available.