NeoAgi.Threading.RateLimiting 9.0.0

dotnet add package NeoAgi.Threading.RateLimiting --version 9.0.0
                    
NuGet\Install-Package NeoAgi.Threading.RateLimiting -Version 9.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NeoAgi.Threading.RateLimiting" Version="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NeoAgi.Threading.RateLimiting" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NeoAgi.Threading.RateLimiting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NeoAgi.Threading.RateLimiting --version 9.0.0
                    
#r "nuget: NeoAgi.Threading.RateLimiting, 9.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NeoAgi.Threading.RateLimiting@9.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NeoAgi.Threading.RateLimiting&version=9.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NeoAgi.Threading.RateLimiting&version=9.0.0
                    
Install as a Cake Tool

Overview

This library does not intend to replace the System.Threading.RateLimiting Namespace. Simply make working with some aspects of it easier under some contexts.

Extension Methods

ConcurrentQueue<T>

Processing a ConcurrentQueue will continue until the cancellation token is cancelled or the queue is empty allowing for work to add more work which will be completed.

ProcessWithTPSAsync()

This abtraction calls TokenBucketRateLimiter with options designed to keep the calls to this function below a set Transactions Per Second by using assumptions.

This call does not attmpet to keep the throughput at the set TPS, but will ensure it will not go over that set amount. In testing TPS can only be reached with a high concurrency value.

Concurrency does not directly imply the number of threas as that depends on how the work is performed within the callback. General guidance is to set concurrency proprotational to the complexity of the call, lower values for callbacks that complete quickly, larger for callbacks that require more time.

Example Call:

var stringQueue = new ConcurrentQueue<string>();
// Fill the queue
await stringQueue.ProcessWithTPSAsync(100, 10, async (action) =>
{
    // Perform work once TPS falls below the threshold
});

The above configuration will execute 10 concurrent tasks executing no more than 100 per second.

ProcessWithRateLimitAsync()

This abstraction resides just above the TokenBucketRateLimiter exposing most of the core API with added clarity to the options.

If processing of the queue is intended to be handled by multiple threads or further tuning of the delegation to worker threads, this extension is more appropriate to use.

Example Call:

var stringQueue = new ConcurrentQueue<string>();
// Fill the queue
await stringQueue.ProcessWithRateLimitAsync(new ThroughputConcurrencyOptions()
{
    ConcurrencyLimit = 20,
    ReplinshmentPeriod = TimeSpan.FromSeconds(10),
    TasksPerPeriod = 50
}, async (value) =>
{
    // Do work
});

The above configuration will pop tasks off of the queue keeping 20 active at a time, blocking once 50 tasks have been completed within a 10 second period.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.0 32,149 11/5/2025
0.1.0 36,869 10/15/2023