Skip to content

A class that uses SemaphoreSlim but allows a negative initialCount. This could be used, for example, when starting to throttle requests but initially already have more concurrent requests than the maximum you want to start allowing.

License

Notifications You must be signed in to change notification settings

MarkCiliaVincenti/SemaphoreSlimThrottling

Repository files navigation

SemaphoreSlimThrottling SemaphoreSlimThrottling

GitHub Workflow Status Nuget Nuget Codacy Grade

A .NET Standard 2.0 library that provides a class that uses SemaphoreSlim but allows a negative initialCount. This could be used, for example, when starting to throttle requests but initially already have more concurrent requests than the maximum you want to start allowing.

Supports .NET Framework 4.6.1 or later, .NET Core 2.0 or later, and .NET 5.0 or later.

Installation

The recommended means is to use NuGet, but you could also download the source code from here.

Usage

// there are 11 concurrent requests, and we want to start limiting to 10.
// SemaphoreSlim does not allow negative initialCount.
var mySemaphore = new SemaphoreSlimThrottle(-1, 10);

For more information, read the documentation for SemaphoreSlim.

About

A class that uses SemaphoreSlim but allows a negative initialCount. This could be used, for example, when starting to throttle requests but initially already have more concurrent requests than the maximum you want to start allowing.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages