← Interactive API Explorer
Namespace: System.Threading

Semaphore

Limits the number of threads that can access a resource or pool of resources concurrently.

Methods (2)

Semaphore(Int32,Int32)Constructor
Initializes a new instance of the Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries.
ParameterDescription
initialCountThe initial number of requests for the semaphore that can be granted concurrently.
maximumCountThe maximum number of requests for the semaphore that can be granted concurrently.
int Release(Int32)
Exits the semaphore a specified number of times and returns the previous count.
ParameterDescription
releaseCountThe number of times to exit the semaphore.
Returns: The count on the semaphore before the Release method was called.