Soenneker.Utils.RateLimiting.Executor 3.0.326

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.326                
NuGet\Install-Package Soenneker.Utils.RateLimiting.Executor -Version 3.0.326                
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.326" />                
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.326                
#r "nuget: Soenneker.Utils.RateLimiting.Executor, 3.0.326"                
#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.326

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

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.330 123 2/25/2025
3.0.329 101 2/25/2025
3.0.328 133 2/25/2025
3.0.327 183 2/25/2025
3.0.326 140 2/25/2025
3.0.325 362 2/23/2025
3.0.324 136 2/23/2025
3.0.323 75 2/22/2025
3.0.322 339 2/22/2025
3.0.321 167 2/22/2025
3.0.320 118 2/22/2025
3.0.319 176 2/22/2025
3.0.318 78 2/21/2025
3.0.317 202 2/21/2025
3.0.316 252 2/21/2025
3.0.315 304 2/19/2025
3.0.314 116 2/19/2025
3.0.313 117 2/19/2025
3.0.312 88 2/18/2025
3.0.311 299 2/18/2025
3.0.310 155 2/18/2025
3.0.309 85 2/18/2025
3.0.308 435 2/14/2025
3.0.307 83 2/14/2025
3.0.306 160 2/13/2025
3.0.305 388 2/12/2025
3.0.304 105 2/12/2025
3.0.303 174 2/12/2025
3.0.302 176 2/11/2025
3.0.301 167 2/11/2025
3.0.300 292 2/11/2025
3.0.299 232 2/11/2025
3.0.298 84 2/11/2025
3.0.297 168 2/11/2025
3.0.296 184 2/10/2025
3.0.295 133 2/10/2025
3.0.294 182 2/10/2025
3.0.293 83 2/10/2025
3.0.292 85 2/10/2025
3.0.291 370 2/9/2025
3.0.290 98 2/8/2025
3.0.289 72 2/8/2025
3.0.288 76 2/8/2025
3.0.287 83 2/8/2025
3.0.286 303 2/8/2025
3.0.285 99 2/7/2025
3.0.284 131 2/7/2025
3.0.283 244 2/7/2025
3.0.282 81 2/7/2025
3.0.281 78 2/7/2025
3.0.280 75 2/7/2025
3.0.279 124 2/7/2025
3.0.278 75 2/7/2025
3.0.277 89 2/7/2025
3.0.276 367 2/6/2025
3.0.275 239 2/5/2025
3.0.274 154 2/5/2025
3.0.273 82 2/5/2025
3.0.272 96 2/5/2025
3.0.271 227 2/5/2025
3.0.270 88 2/5/2025
3.0.269 82 2/5/2025
3.0.268 494 1/28/2025
3.0.267 80 1/28/2025
3.0.266 94 1/28/2025
3.0.265 310 1/27/2025
3.0.264 90 1/27/2025
3.0.263 70 1/27/2025
3.0.262 68 1/27/2025
3.0.261 134 1/27/2025
3.0.260 94 1/27/2025
3.0.259 269 1/26/2025
3.0.258 95 1/26/2025
3.0.257 87 1/26/2025
3.0.256 71 1/26/2025
3.0.255 164 1/25/2025
3.0.254 198 1/25/2025
3.0.253 78 1/25/2025
3.0.252 73 1/25/2025
3.0.251 71 1/25/2025
3.0.250 187 1/25/2025
3.0.249 364 1/24/2025
3.0.248 116 1/24/2025
3.0.247 184 1/24/2025
3.0.246 143 1/24/2025
3.0.245 244 1/24/2025
3.0.244 179 1/23/2025
3.0.243 252 1/21/2025
3.0.242 83 1/21/2025
3.0.241 161 1/21/2025
3.0.240 88 1/21/2025
3.0.239 75 1/21/2025
3.0.238 272 1/21/2025
3.0.237 81 1/21/2025
3.0.236 78 1/21/2025
3.0.235 72 1/21/2025
3.0.234 77 1/21/2025
3.0.233 75 1/20/2025
3.0.232 91 1/20/2025
3.0.231 561 1/20/2025
3.0.230 85 1/20/2025
3.0.229 76 1/20/2025
3.0.228 229 1/20/2025
3.0.227 1,813 1/14/2025
3.0.226 57 1/14/2025
3.0.225 72 1/14/2025
3.0.224 128 1/14/2025
3.0.223 181 1/13/2025
3.0.222 168 1/13/2025
3.0.221 115 1/13/2025
3.0.220 71 1/13/2025
3.0.219 62 1/13/2025
3.0.218 207 1/12/2025
3.0.217 152 1/11/2025
3.0.216 120 1/11/2025
3.0.215 125 1/11/2025
3.0.214 81 1/11/2025
3.0.213 123 1/10/2025
3.0.212 80 1/10/2025
3.0.211 74 1/10/2025
3.0.210 76 1/10/2025
3.0.209 224 1/10/2025
3.0.208 86 1/10/2025
3.0.207 82 1/10/2025
3.0.206 629 1/3/2025
3.0.205 112 1/3/2025
3.0.204 159 1/3/2025
3.0.203 108 1/3/2025
3.0.202 186 1/2/2025
3.0.201 88 1/2/2025
3.0.200 85 1/2/2025
3.0.199 170 1/2/2025
3.0.198 84 1/2/2025
3.0.197 88 1/2/2025
3.0.196 390 1/1/2025
3.0.195 167 1/1/2025
3.0.194 99 1/1/2025
3.0.193 115 1/1/2025
3.0.192 202 1/1/2025
3.0.191 92 1/1/2025
3.0.190 97 1/1/2025
3.0.189 101 12/31/2024
3.0.188 91 12/31/2024
3.0.187 94 12/31/2024
3.0.186 93 12/31/2024
3.0.185 86 12/31/2024
3.0.184 145 12/31/2024
3.0.183 98 12/31/2024
3.0.182 384 12/31/2024
3.0.181 82 12/31/2024
3.0.180 246 12/31/2024
3.0.179 145 12/31/2024
3.0.178 87 12/31/2024
3.0.177 89 12/31/2024
3.0.176 90 12/31/2024
3.0.175 80 12/31/2024
3.0.174 109 12/30/2024
3.0.173 348 12/28/2024
3.0.172 105 12/28/2024
3.0.171 146 12/27/2024
3.0.170 89 12/27/2024
3.0.169 417 12/24/2024
3.0.168 184 12/24/2024
3.0.167 114 12/24/2024
3.0.166 95 12/24/2024
3.0.165 177 12/24/2024
3.0.164 82 12/24/2024
3.0.163 174 12/24/2024
3.0.162 78 12/24/2024
3.0.161 121 12/24/2024
3.0.160 94 12/23/2024
3.0.159 153 12/23/2024
3.0.158 165 12/23/2024
3.0.157 89 12/23/2024
3.0.156 262 12/23/2024
3.0.155 108 12/23/2024
3.0.154 247 12/22/2024
3.0.153 88 12/22/2024
3.0.152 87 12/22/2024
3.0.151 200 12/22/2024
3.0.150 94 12/22/2024
3.0.149 89 12/22/2024
3.0.148 82 12/22/2024
3.0.147 266 12/22/2024
3.0.146 89 12/22/2024
3.0.145 100 12/22/2024
3.0.144 89 12/22/2024
3.0.143 254 12/21/2024
3.0.142 89 12/21/2024
3.0.141 100 12/21/2024
3.0.140 85 12/21/2024
3.0.139 88 12/21/2024
3.0.138 83 12/21/2024
3.0.137 84 12/21/2024
3.0.136 91 12/21/2024
3.0.135 275 12/21/2024
3.0.134 170 12/21/2024
3.0.133 84 12/21/2024
3.0.132 87 12/21/2024
3.0.131 77 12/21/2024
3.0.130 232 12/21/2024
3.0.129 86 12/21/2024
3.0.128 138 12/20/2024
3.0.127 81 12/20/2024
3.0.126 161 12/20/2024
3.0.125 84 12/20/2024
3.0.124 185 12/20/2024
3.0.123 160 12/20/2024
3.0.122 90 12/20/2024
3.0.121 163 12/20/2024
3.0.120 187 12/19/2024
3.0.119 162 12/19/2024
3.0.118 95 12/19/2024
3.0.117 139 12/19/2024
3.0.116 88 12/18/2024
3.0.115 136 12/18/2024
3.0.114 193 12/17/2024
3.0.113 105 12/17/2024
3.0.112 68 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 170 12/10/2024
3.0.107 89 12/9/2024
3.0.106 172 12/9/2024
3.0.105 208 12/9/2024
3.0.104 83 12/9/2024
3.0.103 287 12/7/2024
3.0.102 109 12/6/2024
3.0.101 108 12/6/2024
3.0.100 102 12/6/2024
3.0.99 107 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 92 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 132 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 96 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 89 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 136 11/14/2024
3.0.40 102 11/14/2024
3.0.39 214 11/14/2024
3.0.38 311 11/14/2024
3.0.37 156 11/14/2024
3.0.36 92 11/14/2024
3.0.35 94 11/14/2024
3.0.34 139 11/14/2024
3.0.33 95 11/14/2024
3.0.32 191 11/14/2024
2.1.31 293 11/13/2024
2.1.30 180 11/13/2024
2.1.29 256 11/13/2024
2.1.28 143 11/12/2024
2.1.27 87 11/12/2024
2.1.26 647 11/9/2024
2.1.25 179 11/9/2024
2.1.24 339 11/8/2024
2.1.23 103 11/8/2024
2.1.22 93 11/8/2024
2.1.21 288 11/8/2024
2.1.20 232 11/8/2024
2.1.19 259 11/6/2024
2.1.18 330 11/1/2024
2.1.17 91 11/1/2024
2.1.16 318 11/1/2024
2.1.14 107 10/29/2024
2.1.13 256 10/29/2024
2.1.12 144 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