SemaphoreSlim Constructors
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the SemaphoreSlim class.
SemaphoreSlim(Int32) |
Initializes a new instance of the SemaphoreSlim class, specifying the initial number of requests that can be granted concurrently. |
SemaphoreSlim(Int32, Int32) |
Initializes a new instance of the SemaphoreSlim class, specifying the initial and maximum number of requests that can be granted concurrently. |
- Source:
- SemaphoreSlim.cs
- Source:
- SemaphoreSlim.cs
- Source:
- SemaphoreSlim.cs
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
The initial number of requests for the semaphore that can be granted concurrently.
Exceptions
initialCount
is less than 0.
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
Applies to
.NET 9 en andere versies
Product | Versies |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
- Source:
- SemaphoreSlim.cs
- Source:
- SemaphoreSlim.cs
- Source:
- SemaphoreSlim.cs
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
The initial number of requests for the semaphore that can be granted concurrently.
- maxCount
- 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
.NET 9 en andere versies
Product | Versies |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET-feedback
.NET is een open source project. Selecteer een koppeling om feedback te geven: