Soenneker.Utils.RateLimiting.Executor 3.0.169

Prefix Reserved
dotnet add package Soenneker.Utils.RateLimiting.Executor --version 3.0.169                
NuGet\Install-Package Soenneker.Utils.RateLimiting.Executor -Version 3.0.169                
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="Soenneker.Utils.RateLimiting.Executor" Version="3.0.169" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.RateLimiting.Executor --version 3.0.169                
#r "nuget: Soenneker.Utils.RateLimiting.Executor, 3.0.169"                
#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.
// Install Soenneker.Utils.RateLimiting.Executor as a Cake Addin
#addin nuget:?package=Soenneker.Utils.RateLimiting.Executor&version=3.0.169

// Install Soenneker.Utils.RateLimiting.Executor as a Cake Tool
#tool nuget:?package=Soenneker.Utils.RateLimiting.Executor&version=3.0.169                

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.RateLimiting.Executor

A thread-safe utility designed to manage the rate at which tasks are executed, ensuring they are not run more frequently than a specified interval.

RateLimitingExecutor is ideal for interacting with rate-limited APIs or throttling the execution of resource-intensive tasks.

Sequential Execution

Tasks, ValueTasks, and Actions are executed one at a time. If the defined interval between executions has passed, the task runs immediately; otherwise, it waits until the interval elapses before proceeding.

⚠️ Important Notes:

  • This is not a background queue processor. Each method awaits the result of the asynchronous operation before continuing.

  • Asynchronous methods will not block the calling thread, but synchronous methods will block execution until it completes.

Want to use this with dependency injection?

Check out the singleton factory implementation: Soenneker.Utils.RateLimiting.Factory

Installation

dotnet add package Soenneker.Utils.RateLimiting.Executor

Example: Executing a Loop of Tasks with Rate Limiting

Below is an example demonstrating how to use the RateLimitingExecutor to execute a series of tasks while maintaining a rate limit.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Soenneker.Utils.RateLimiting.Executor;

public class Program
{
    public static async Task Main(string[] args)
    {
        var rateLimitingExecutor = new RateLimitingExecutor(TimeSpan.FromSeconds(2));

        for (int i = 0; i < 5; i++)
        {
            await rateLimitingExecutor.Execute(async ct =>
            {
                Console.WriteLine($"Executing Task {i + 1} at {DateTime.Now:HH:mm:ss}");
                await Task.Delay(100); // Simulate some work
            });
        }
    }
}

Console Output

Executing Task 1 at 14:00:00
Executing Task 2 at 14:00:02
Executing Task 3 at 14:00:04
Executing Task 4 at 14:00:06
Executing Task 5 at 14:00:08
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Utils.RateLimiting.Executor:

Package Downloads
Soenneker.Utils.RateLimiting.Factory

An async thread-safe singleton dictionary for Soenneker.Utils.RateLimiting.Executors, designed to manage the rate at which tasks are executed.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.169 153 12/24/2024
3.0.168 143 12/24/2024
3.0.167 92 12/24/2024
3.0.166 75 12/24/2024
3.0.165 154 12/24/2024
3.0.164 65 12/24/2024
3.0.163 157 12/24/2024
3.0.162 59 12/24/2024
3.0.161 102 12/24/2024
3.0.160 77 12/23/2024
3.0.159 134 12/23/2024
3.0.158 148 12/23/2024
3.0.157 73 12/23/2024
3.0.156 242 12/23/2024
3.0.155 88 12/23/2024
3.0.154 231 12/22/2024
3.0.153 72 12/22/2024
3.0.152 69 12/22/2024
3.0.151 182 12/22/2024
3.0.150 76 12/22/2024
3.0.149 71 12/22/2024
3.0.148 66 12/22/2024
3.0.147 250 12/22/2024
3.0.146 73 12/22/2024
3.0.145 79 12/22/2024
3.0.144 70 12/22/2024
3.0.143 236 12/21/2024
3.0.142 71 12/21/2024
3.0.141 82 12/21/2024
3.0.140 67 12/21/2024
3.0.139 72 12/21/2024
3.0.138 65 12/21/2024
3.0.137 68 12/21/2024
3.0.136 73 12/21/2024
3.0.135 258 12/21/2024
3.0.134 154 12/21/2024
3.0.133 68 12/21/2024
3.0.132 71 12/21/2024
3.0.131 61 12/21/2024
3.0.130 215 12/21/2024
3.0.129 69 12/21/2024
3.0.128 119 12/20/2024
3.0.127 63 12/20/2024
3.0.126 145 12/20/2024
3.0.125 68 12/20/2024
3.0.124 169 12/20/2024
3.0.123 144 12/20/2024
3.0.122 72 12/20/2024
3.0.121 146 12/20/2024
3.0.120 170 12/19/2024
3.0.119 144 12/19/2024
3.0.118 78 12/19/2024
3.0.117 124 12/19/2024
3.0.116 71 12/18/2024
3.0.115 119 12/18/2024
3.0.114 176 12/17/2024
3.0.113 89 12/17/2024
3.0.112 51 12/17/2024
3.0.111 187 12/16/2024
3.0.110 271 12/10/2024
3.0.109 72 12/10/2024
3.0.108 152 12/10/2024
3.0.107 74 12/9/2024
3.0.106 157 12/9/2024
3.0.105 189 12/9/2024
3.0.104 70 12/9/2024
3.0.103 272 12/7/2024
3.0.102 95 12/6/2024
3.0.101 87 12/6/2024
3.0.100 89 12/6/2024
3.0.99 92 12/6/2024
3.0.97 119 12/6/2024
3.0.96 100 12/6/2024
3.0.95 75 12/6/2024
3.0.94 77 12/6/2024
3.0.93 78 12/6/2024
3.0.92 78 12/6/2024
3.0.91 113 12/6/2024
3.0.90 106 12/5/2024
3.0.89 102 12/5/2024
3.0.88 656 12/5/2024
3.0.87 114 12/5/2024
3.0.86 116 12/5/2024
3.0.85 166 12/5/2024
3.0.84 100 12/4/2024
3.0.83 125 12/4/2024
3.0.82 181 12/4/2024
3.0.81 163 12/4/2024
3.0.80 151 12/4/2024
3.0.79 78 12/3/2024
3.0.78 174 12/3/2024
3.0.77 173 12/3/2024
3.0.76 134 12/3/2024
3.0.75 68 12/3/2024
3.0.74 119 12/3/2024
3.0.73 65 12/3/2024
3.0.72 337 12/2/2024
3.0.71 127 12/2/2024
3.0.70 145 12/2/2024
3.0.69 72 12/2/2024
3.0.68 144 12/2/2024
3.0.67 194 12/1/2024
3.0.66 74 12/1/2024
3.0.65 232 12/1/2024
3.0.64 106 12/1/2024
3.0.63 186 11/29/2024
3.0.62 154 11/29/2024
3.0.61 241 11/21/2024
3.0.60 91 11/21/2024
3.0.59 243 11/20/2024
3.0.58 77 11/20/2024
3.0.57 105 11/20/2024
3.0.56 82 11/20/2024
3.0.55 82 11/20/2024
3.0.54 94 11/20/2024
3.0.53 89 11/19/2024
3.0.52 78 11/19/2024
3.0.51 76 11/19/2024
3.0.50 365 11/19/2024
3.0.49 73 11/19/2024
3.0.48 292 11/19/2024
3.0.47 78 11/19/2024
3.0.46 76 11/19/2024
3.0.45 277 11/15/2024
3.0.44 122 11/14/2024
3.0.43 74 11/14/2024
3.0.42 74 11/14/2024
3.0.41 122 11/14/2024
3.0.40 90 11/14/2024
3.0.39 200 11/14/2024
3.0.38 299 11/14/2024
3.0.37 142 11/14/2024
3.0.36 77 11/14/2024
3.0.35 79 11/14/2024
3.0.34 124 11/14/2024
3.0.33 80 11/14/2024
3.0.32 177 11/14/2024
2.1.31 279 11/13/2024
2.1.30 168 11/13/2024
2.1.29 238 11/13/2024
2.1.28 129 11/12/2024
2.1.27 74 11/12/2024
2.1.26 632 11/9/2024
2.1.25 164 11/9/2024
2.1.24 324 11/8/2024
2.1.23 82 11/8/2024
2.1.22 79 11/8/2024
2.1.21 273 11/8/2024
2.1.20 217 11/8/2024
2.1.19 239 11/6/2024
2.1.18 317 11/1/2024
2.1.17 77 11/1/2024
2.1.16 305 11/1/2024
2.1.14 91 10/29/2024
2.1.13 240 10/29/2024
2.1.12 128 10/29/2024
2.1.11 397 10/29/2024
2.1.10 241 10/28/2024
2.1.9 75 10/28/2024
2.1.8 105 10/28/2024
2.1.7 341 10/26/2024
2.1.6 103 10/26/2024
2.1.5 247 10/22/2024
2.1.4 105 10/22/2024
2.1.3 80 10/22/2024
2.1.2 89 10/22/2024
2.1.1 109 10/22/2024