Soenneker.Utils.RateLimiting.Executor 3.0.271

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.RateLimiting.Executor --version 3.0.271                
NuGet\Install-Package Soenneker.Utils.RateLimiting.Executor -Version 3.0.271                
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.271" />                
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.271                
#r "nuget: Soenneker.Utils.RateLimiting.Executor, 3.0.271"                
#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.271

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

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.  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. 
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.300 0 2/11/2025
3.0.299 0 2/11/2025
3.0.298 0 2/11/2025
3.0.297 26 2/11/2025
3.0.296 76 2/10/2025
3.0.295 61 2/10/2025
3.0.294 89 2/10/2025
3.0.293 32 2/10/2025
3.0.292 35 2/10/2025
3.0.291 196 2/9/2025
3.0.290 48 2/8/2025
3.0.289 32 2/8/2025
3.0.288 33 2/8/2025
3.0.287 42 2/8/2025
3.0.286 155 2/8/2025
3.0.285 48 2/7/2025
3.0.284 70 2/7/2025
3.0.283 134 2/7/2025
3.0.282 38 2/7/2025
3.0.281 35 2/7/2025
3.0.280 36 2/7/2025
3.0.279 53 2/7/2025
3.0.278 32 2/7/2025
3.0.277 33 2/7/2025
3.0.276 126 2/6/2025
3.0.275 100 2/5/2025
3.0.274 100 2/5/2025
3.0.273 72 2/5/2025
3.0.272 83 2/5/2025
3.0.271 138 2/5/2025
3.0.270 77 2/5/2025
3.0.269 71 2/5/2025
3.0.268 312 1/28/2025
3.0.267 37 1/28/2025
3.0.266 47 1/28/2025
3.0.265 253 1/27/2025
3.0.264 39 1/27/2025
3.0.263 33 1/27/2025
3.0.262 30 1/27/2025
3.0.261 83 1/27/2025
3.0.260 46 1/27/2025
3.0.259 212 1/26/2025
3.0.258 46 1/26/2025
3.0.257 45 1/26/2025
3.0.256 30 1/26/2025
3.0.255 118 1/25/2025
3.0.254 146 1/25/2025
3.0.253 35 1/25/2025
3.0.252 34 1/25/2025
3.0.251 32 1/25/2025
3.0.250 122 1/25/2025
3.0.249 224 1/24/2025
3.0.248 33 1/24/2025
3.0.247 103 1/24/2025
3.0.246 90 1/24/2025
3.0.245 173 1/24/2025
3.0.244 114 1/23/2025
3.0.243 238 1/21/2025
3.0.242 71 1/21/2025
3.0.241 144 1/21/2025
3.0.240 75 1/21/2025
3.0.239 64 1/21/2025
3.0.238 257 1/21/2025
3.0.237 69 1/21/2025
3.0.236 62 1/21/2025
3.0.235 61 1/21/2025
3.0.234 63 1/21/2025
3.0.233 64 1/20/2025
3.0.232 80 1/20/2025
3.0.231 548 1/20/2025
3.0.230 71 1/20/2025
3.0.229 62 1/20/2025
3.0.228 217 1/20/2025
3.0.227 1,781 1/14/2025
3.0.226 35 1/14/2025
3.0.225 42 1/14/2025
3.0.224 60 1/14/2025
3.0.223 141 1/13/2025
3.0.222 111 1/13/2025
3.0.221 90 1/13/2025
3.0.220 64 1/13/2025
3.0.219 55 1/13/2025
3.0.218 148 1/12/2025
3.0.217 111 1/11/2025
3.0.216 89 1/11/2025
3.0.215 101 1/11/2025
3.0.214 69 1/11/2025
3.0.213 99 1/10/2025
3.0.212 69 1/10/2025
3.0.211 66 1/10/2025
3.0.210 68 1/10/2025
3.0.209 159 1/10/2025
3.0.208 74 1/10/2025
3.0.207 73 1/10/2025
3.0.206 511 1/3/2025
3.0.205 99 1/3/2025
3.0.204 140 1/3/2025
3.0.203 95 1/3/2025
3.0.202 173 1/2/2025
3.0.201 75 1/2/2025
3.0.200 72 1/2/2025
3.0.199 157 1/2/2025
3.0.198 71 1/2/2025
3.0.197 75 1/2/2025
3.0.196 387 1/1/2025
3.0.195 164 1/1/2025
3.0.194 96 1/1/2025
3.0.193 112 1/1/2025
3.0.192 199 1/1/2025
3.0.191 89 1/1/2025
3.0.190 94 1/1/2025
3.0.189 100 12/31/2024
3.0.188 88 12/31/2024
3.0.187 91 12/31/2024
3.0.186 92 12/31/2024
3.0.185 85 12/31/2024
3.0.184 144 12/31/2024
3.0.183 97 12/31/2024
3.0.182 382 12/31/2024
3.0.181 80 12/31/2024
3.0.180 242 12/31/2024
3.0.179 143 12/31/2024
3.0.178 85 12/31/2024
3.0.177 87 12/31/2024
3.0.176 86 12/31/2024
3.0.175 78 12/31/2024
3.0.174 107 12/30/2024
3.0.173 344 12/28/2024
3.0.172 104 12/28/2024
3.0.171 143 12/27/2024
3.0.170 86 12/27/2024
3.0.169 414 12/24/2024
3.0.168 183 12/24/2024
3.0.167 113 12/24/2024
3.0.166 92 12/24/2024
3.0.165 176 12/24/2024
3.0.164 81 12/24/2024
3.0.163 173 12/24/2024
3.0.162 75 12/24/2024
3.0.161 118 12/24/2024
3.0.160 93 12/23/2024
3.0.159 150 12/23/2024
3.0.158 164 12/23/2024
3.0.157 88 12/23/2024
3.0.156 261 12/23/2024
3.0.155 107 12/23/2024
3.0.154 246 12/22/2024
3.0.153 87 12/22/2024
3.0.152 84 12/22/2024
3.0.151 197 12/22/2024
3.0.150 91 12/22/2024
3.0.149 86 12/22/2024
3.0.148 81 12/22/2024
3.0.147 265 12/22/2024
3.0.146 88 12/22/2024
3.0.145 96 12/22/2024
3.0.144 86 12/22/2024
3.0.143 251 12/21/2024
3.0.142 86 12/21/2024
3.0.141 97 12/21/2024
3.0.140 82 12/21/2024
3.0.139 87 12/21/2024
3.0.138 80 12/21/2024
3.0.137 83 12/21/2024
3.0.136 88 12/21/2024
3.0.135 273 12/21/2024
3.0.134 169 12/21/2024
3.0.133 83 12/21/2024
3.0.132 86 12/21/2024
3.0.131 76 12/21/2024
3.0.130 231 12/21/2024
3.0.129 85 12/21/2024
3.0.128 135 12/20/2024
3.0.127 78 12/20/2024
3.0.126 160 12/20/2024
3.0.125 83 12/20/2024
3.0.124 184 12/20/2024
3.0.123 159 12/20/2024
3.0.122 87 12/20/2024
3.0.121 161 12/20/2024
3.0.120 185 12/19/2024
3.0.119 159 12/19/2024
3.0.118 93 12/19/2024
3.0.117 139 12/19/2024
3.0.116 86 12/18/2024
3.0.115 134 12/18/2024
3.0.114 191 12/17/2024
3.0.113 103 12/17/2024
3.0.112 66 12/17/2024
3.0.111 202 12/16/2024
3.0.110 284 12/10/2024
3.0.109 85 12/10/2024
3.0.108 168 12/10/2024
3.0.107 87 12/9/2024
3.0.106 170 12/9/2024
3.0.105 202 12/9/2024
3.0.104 83 12/9/2024
3.0.103 285 12/7/2024
3.0.102 109 12/6/2024
3.0.101 100 12/6/2024
3.0.100 102 12/6/2024
3.0.99 105 12/6/2024
3.0.97 132 12/6/2024
3.0.96 113 12/6/2024
3.0.95 90 12/6/2024
3.0.94 90 12/6/2024
3.0.93 93 12/6/2024
3.0.92 93 12/6/2024
3.0.91 128 12/6/2024
3.0.90 119 12/5/2024
3.0.89 116 12/5/2024
3.0.88 671 12/5/2024
3.0.87 130 12/5/2024
3.0.86 136 12/5/2024
3.0.85 181 12/5/2024
3.0.84 113 12/4/2024
3.0.83 138 12/4/2024
3.0.82 196 12/4/2024
3.0.81 182 12/4/2024
3.0.80 164 12/4/2024
3.0.79 93 12/3/2024
3.0.78 187 12/3/2024
3.0.77 188 12/3/2024
3.0.76 149 12/3/2024
3.0.75 81 12/3/2024
3.0.74 134 12/3/2024
3.0.73 80 12/3/2024
3.0.72 352 12/2/2024
3.0.71 142 12/2/2024
3.0.70 160 12/2/2024
3.0.69 87 12/2/2024
3.0.68 163 12/2/2024
3.0.67 207 12/1/2024
3.0.66 89 12/1/2024
3.0.65 245 12/1/2024
3.0.64 124 12/1/2024
3.0.63 196 11/29/2024
3.0.62 166 11/29/2024
3.0.61 253 11/21/2024
3.0.60 103 11/21/2024
3.0.59 253 11/20/2024
3.0.58 95 11/20/2024
3.0.57 117 11/20/2024
3.0.56 94 11/20/2024
3.0.55 94 11/20/2024
3.0.54 106 11/20/2024
3.0.53 101 11/19/2024
3.0.52 93 11/19/2024
3.0.51 89 11/19/2024
3.0.50 378 11/19/2024
3.0.49 83 11/19/2024
3.0.48 302 11/19/2024
3.0.47 88 11/19/2024
3.0.46 92 11/19/2024
3.0.45 289 11/15/2024
3.0.44 135 11/14/2024
3.0.43 90 11/14/2024
3.0.42 87 11/14/2024
3.0.41 135 11/14/2024
3.0.40 101 11/14/2024
3.0.39 213 11/14/2024
3.0.38 310 11/14/2024
3.0.37 155 11/14/2024
3.0.36 90 11/14/2024
3.0.35 92 11/14/2024
3.0.34 137 11/14/2024
3.0.33 93 11/14/2024
3.0.32 190 11/14/2024
2.1.31 292 11/13/2024
2.1.30 179 11/13/2024
2.1.29 255 11/13/2024
2.1.28 142 11/12/2024
2.1.27 85 11/12/2024
2.1.26 645 11/9/2024
2.1.25 177 11/9/2024
2.1.24 338 11/8/2024
2.1.23 99 11/8/2024
2.1.22 92 11/8/2024
2.1.21 287 11/8/2024
2.1.20 231 11/8/2024
2.1.19 258 11/6/2024
2.1.18 328 11/1/2024
2.1.17 90 11/1/2024
2.1.16 317 11/1/2024
2.1.14 107 10/29/2024
2.1.13 256 10/29/2024
2.1.12 142 10/29/2024
2.1.11 413 10/29/2024
2.1.10 255 10/28/2024
2.1.9 94 10/28/2024
2.1.8 124 10/28/2024
2.1.7 355 10/26/2024
2.1.6 114 10/26/2024
2.1.5 259 10/22/2024
2.1.4 115 10/22/2024
2.1.3 92 10/22/2024
2.1.2 101 10/22/2024
2.1.1 119 10/22/2024