Semaphore.WaitAsync method (1 of 6)

Asynchronously waits to enter the semaphore.

public virtual Task WaitAsync()

Return Value

A task that will complete when the semaphore has been entered.

See Also


Semaphore.WaitAsync method (2 of 6)

Asynchronously waits to enter the semaphore, while observing a CancellationToken.

public virtual Task WaitAsync(CancellationToken cancellationToken)
parameter description
cancellationToken The CancellationToken to observe.

Return Value

A task that will complete when the semaphore has been entered.

See Also


Semaphore.WaitAsync method (3 of 6)

Asynchronously waits to enter the semaphore, using a 32-bit signed integer that specifies the timeout.

public virtual Task<bool> WaitAsync(int millisecondsTimeout)
parameter description
millisecondsTimeout The number of milliseconds to wait, Infinite (-1) to wait indefinitely, or zero to test the state of the wait handle and return immediately.

Return Value

A task that will complete with a result of true if the current thread successfully entered the semaphore, otherwise with a result of false.

See Also


Semaphore.WaitAsync method (4 of 6)

Asynchronously waits to enter the semaphore, using a TimeSpan that specifies the timeout.

public virtual Task<bool> WaitAsync(TimeSpan timeout)
parameter description
timeout A TimeSpan that represents the number of milliseconds to wait, a TimeSpan that represents -1 milliseconds to wait indefinitely, or a TimeSpan that represents 0 milliseconds to test the wait handle and return immediately.

Return Value

A task that will complete with a result of true if the current thread successfully entered the semaphore, otherwise with a result of false.

See Also


Semaphore.WaitAsync method (5 of 6)

Asynchronously waits to enter the semaphore, using a 32-bit signed integer that specifies the timeout, while observing a CancellationToken.

public virtual Task<bool> WaitAsync(int millisecondsTimeout, CancellationToken cancellationToken)
parameter description
millisecondsTimeout The number of milliseconds to wait, Infinite (-1) to wait indefinitely, or zero to test the state of the wait handle and return immediately.
cancellationToken The CancellationToken to observe.

Return Value

A task that will complete with a result of true if the current thread successfully entered the semaphore, otherwise with a result of false.

See Also


Semaphore.WaitAsync method (6 of 6)

Asynchronously waits to enter the semaphore, using a TimeSpan that specifies the timeout, while observing a CancellationToken.

public virtual Task<bool> WaitAsync(TimeSpan timeout, CancellationToken cancellationToken)
parameter description
timeout A TimeSpan that represents the number of milliseconds to wait, a TimeSpan that represents -1 milliseconds to wait indefinitely, or a TimeSpan that represents 0 milliseconds to test the wait handle and return immediately.
cancellationToken The CancellationToken to observe.

Return Value

A task that will complete with a result of true if the current thread successfully entered the semaphore, otherwise with a result of false.

See Also