SemaphoreSlim SemaphoreSlim SemaphoreSlim SemaphoreSlim Constructors

Definition

Overloads

SemaphoreSlim(Int32) SemaphoreSlim(Int32) SemaphoreSlim(Int32) SemaphoreSlim(Int32)

Initializes a new instance of the SemaphoreSlim class, specifying the initial number of requests that can be granted concurrently.

SemaphoreSlim(Int32, Int32) SemaphoreSlim(Int32, Int32) SemaphoreSlim(Int32, Int32) SemaphoreSlim(Int32, Int32)

Initializes a new instance of the SemaphoreSlim class, specifying the initial and maximum number of requests that can be granted concurrently.

SemaphoreSlim(Int32) SemaphoreSlim(Int32) SemaphoreSlim(Int32) SemaphoreSlim(Int32)

Initializes a new instance of the SemaphoreSlim class, specifying the initial number of requests that can be granted concurrently.

public:
 SemaphoreSlim(int initialCount);
public SemaphoreSlim (int initialCount);
new System.Threading.SemaphoreSlim : int -> System.Threading.SemaphoreSlim
Public Sub New (initialCount As Integer)

Parameters

initialCount
Int32 Int32 Int32 Int32

The initial number of requests for the semaphore that can be granted concurrently.

Exceptions

Remarks

The initialCount parameter defines the number of concurrent requests to enter the semaphore that can be granted. However, it doesn't define the maximum number of requests that can be granted concurrently. A SemaphoreSlim object instantiated by calling this constructor doesn't throw a SemaphoreFullException exception if a call to the Release method increases the value of the CurrentCount property beyond initialCount. This occurs if there are more calls to Release methods than there are to Wait or WaitAsync methods. To set the maximum number of concurrent requests to enter the semaphore that can be granted, call the SemaphoreSlim(Int32, Int32) constructor.

See also

SemaphoreSlim(Int32, Int32) SemaphoreSlim(Int32, Int32) SemaphoreSlim(Int32, Int32) SemaphoreSlim(Int32, Int32)

Initializes a new instance of the SemaphoreSlim class, specifying the initial and maximum number of requests that can be granted concurrently.

public:
 SemaphoreSlim(int initialCount, int maxCount);
public SemaphoreSlim (int initialCount, int maxCount);
new System.Threading.SemaphoreSlim : int * int -> System.Threading.SemaphoreSlim
Public Sub New (initialCount As Integer, maxCount As Integer)

Parameters

initialCount
Int32 Int32 Int32 Int32

The initial number of requests for the semaphore that can be granted concurrently.

maxCount
Int32 Int32 Int32 Int32

The maximum number of requests for the semaphore that can be granted concurrently.

Exceptions

initialCount is less than 0, or initialCount is greater than maxCount, or maxCount is equal to or less than 0.

See also

Applies to