Class AsyncSemaphore
A minimal asynchronous semaphore: callers wait with WaitAsync() without blocking a thread and are served in first-in first-out order.
public class AsyncSemaphore
- Inheritance
-
AsyncSemaphore
- Inherited Members
Constructors
AsyncSemaphore(int)
Initializes a new instance of the AsyncSemaphore class.
public AsyncSemaphore(int initialCount)
Parameters
initialCountintThe number of callers that can enter without waiting.
Exceptions
- ArgumentOutOfRangeException
initialCountis negative.
Methods
Release()
Releases the semaphore: the oldest waiter, if any, is resumed; otherwise the available count is incremented.
public void Release()
WaitAsync()
Asynchronously waits to enter the semaphore.
public Task WaitAsync()