Semaphore class

A semaphore that limits the number of tasks that can access a resource. During testing, the semaphore is automatically replaced with a controlled mocked version.

public class Semaphore : IDisposable

Public Members

name description
static Create(…) Creates a new semaphore.
virtual CurrentCount { get; } Number of remaining tasks that can enter the semaphore.
Dispose() Releases resources used by the semaphore.
virtual Release() Releases the semaphore.
virtual Wait() Blocks the current task until it can enter the semaphore.
virtual Wait(…) Blocks the current task until it can enter the semaphore, using a TimeSpan that specifies the timeout. (5 methods)
virtual WaitAsync() Asynchronously waits to enter the semaphore.
virtual WaitAsync(…) Asynchronously waits to enter the semaphore, using a TimeSpan that specifies the timeout. (5 methods)

Protected Members

name description
Semaphore(…) Initializes a new instance of the Semaphore class.

See Also