Soenneker.Utils.RateLimiting.Executor 2.1.26

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 2.1.26                
NuGet\Install-Package Soenneker.Utils.RateLimiting.Executor -Version 2.1.26                
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="2.1.26" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.RateLimiting.Executor --version 2.1.26                
#r "nuget: Soenneker.Utils.RateLimiting.Executor, 2.1.26"                
#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=2.1.26

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

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 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 was computed.  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.357 53 3/15/2025
3.0.356 29 3/15/2025
3.0.355 275 3/12/2025
3.0.354 162 3/12/2025
3.0.353 194 3/12/2025
3.0.352 156 3/11/2025
3.0.351 261 3/11/2025
3.0.350 211 3/11/2025
3.0.349 141 3/11/2025
3.0.348 399 3/11/2025
3.0.347 359 3/7/2025
3.0.346 326 3/7/2025
3.0.345 318 3/2/2025
3.0.344 129 3/2/2025
3.0.343 127 3/2/2025
3.0.342 81 3/2/2025
3.0.341 89 3/2/2025
3.0.340 200 3/2/2025
3.0.339 198 3/1/2025
3.0.338 77 3/1/2025
3.0.337 77 3/1/2025
3.0.336 404 3/1/2025
3.0.335 110 3/1/2025
3.0.334 68 3/1/2025
3.0.333 188 3/1/2025
3.0.332 76 3/1/2025
3.0.331 72 3/1/2025
3.0.330 297 2/25/2025
3.0.329 126 2/25/2025
3.0.328 167 2/25/2025
3.0.327 193 2/25/2025
3.0.326 144 2/25/2025
3.0.325 366 2/23/2025
3.0.324 140 2/23/2025
3.0.323 79 2/22/2025
3.0.322 343 2/22/2025
3.0.321 171 2/22/2025
3.0.320 122 2/22/2025
3.0.319 182 2/22/2025
3.0.318 82 2/21/2025
3.0.317 206 2/21/2025
3.0.316 256 2/21/2025
3.0.315 308 2/19/2025
3.0.314 118 2/19/2025
3.0.313 119 2/19/2025
3.0.312 90 2/18/2025
3.0.311 301 2/18/2025
3.0.310 157 2/18/2025
3.0.309 87 2/18/2025
3.0.308 439 2/14/2025
3.0.307 85 2/14/2025
3.0.306 164 2/13/2025
3.0.305 390 2/12/2025
3.0.304 107 2/12/2025
3.0.303 178 2/12/2025
3.0.302 180 2/11/2025
3.0.301 169 2/11/2025
3.0.300 296 2/11/2025
3.0.299 234 2/11/2025
3.0.298 86 2/11/2025
3.0.297 170 2/11/2025
3.0.296 187 2/10/2025
3.0.295 137 2/10/2025
3.0.294 184 2/10/2025
3.0.293 85 2/10/2025
3.0.292 89 2/10/2025
3.0.291 372 2/9/2025
3.0.290 100 2/8/2025
3.0.289 76 2/8/2025
3.0.288 80 2/8/2025
3.0.287 87 2/8/2025
3.0.286 305 2/8/2025
3.0.285 101 2/7/2025
3.0.284 133 2/7/2025
3.0.283 248 2/7/2025
3.0.282 85 2/7/2025
3.0.281 80 2/7/2025
3.0.280 79 2/7/2025
3.0.279 129 2/7/2025
3.0.278 77 2/7/2025
3.0.277 93 2/7/2025
3.0.276 370 2/6/2025
3.0.275 243 2/5/2025
3.0.274 156 2/5/2025
3.0.273 86 2/5/2025
3.0.272 98 2/5/2025
3.0.271 231 2/5/2025
3.0.270 92 2/5/2025
3.0.269 86 2/5/2025
3.0.268 495 1/28/2025
3.0.267 83 1/28/2025
3.0.266 95 1/28/2025
3.0.265 311 1/27/2025
3.0.264 91 1/27/2025
3.0.263 73 1/27/2025
3.0.262 69 1/27/2025
3.0.261 137 1/27/2025
3.0.260 95 1/27/2025
3.0.259 270 1/26/2025
3.0.258 96 1/26/2025
3.0.257 90 1/26/2025
3.0.256 72 1/26/2025
3.0.255 165 1/25/2025
3.0.254 199 1/25/2025
3.0.253 78 1/25/2025
3.0.252 73 1/25/2025
3.0.251 73 1/25/2025
3.0.250 190 1/25/2025
3.0.249 365 1/24/2025
3.0.248 117 1/24/2025
3.0.247 184 1/24/2025
3.0.246 143 1/24/2025
3.0.245 246 1/24/2025
3.0.244 179 1/23/2025
3.0.243 252 1/21/2025
3.0.242 85 1/21/2025
3.0.241 163 1/21/2025
3.0.240 90 1/21/2025
3.0.239 77 1/21/2025
3.0.238 272 1/21/2025
3.0.237 83 1/21/2025
3.0.236 78 1/21/2025
3.0.235 74 1/21/2025
3.0.234 79 1/21/2025
3.0.233 77 1/20/2025
3.0.232 93 1/20/2025
3.0.231 561 1/20/2025
3.0.230 87 1/20/2025
3.0.229 76 1/20/2025
3.0.228 231 1/20/2025
3.0.227 1,816 1/14/2025
3.0.226 58 1/14/2025
3.0.225 73 1/14/2025
3.0.224 131 1/14/2025
3.0.223 181 1/13/2025
3.0.222 168 1/13/2025
3.0.221 117 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 122 1/11/2025
3.0.215 127 1/11/2025
3.0.214 81 1/11/2025
3.0.213 125 1/10/2025
3.0.212 82 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 84 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 117 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 103 12/31/2024
3.0.188 91 12/31/2024
3.0.187 94 12/31/2024
3.0.186 95 12/31/2024
3.0.185 88 12/31/2024
3.0.184 147 12/31/2024
3.0.183 100 12/31/2024
3.0.182 386 12/31/2024
3.0.181 85 12/31/2024
3.0.180 246 12/31/2024
3.0.179 145 12/31/2024
3.0.178 89 12/31/2024
3.0.177 91 12/31/2024
3.0.176 90 12/31/2024
3.0.175 82 12/31/2024
3.0.174 111 12/30/2024
3.0.173 348 12/28/2024
3.0.172 107 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 186 12/24/2024
3.0.167 116 12/24/2024
3.0.166 95 12/24/2024
3.0.165 179 12/24/2024
3.0.164 84 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 96 12/23/2024
3.0.159 153 12/23/2024
3.0.158 167 12/23/2024
3.0.157 91 12/23/2024
3.0.156 263 12/23/2024
3.0.155 108 12/23/2024
3.0.154 249 12/22/2024
3.0.153 90 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 84 12/22/2024
3.0.147 268 12/22/2024
3.0.146 91 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 90 12/21/2024
3.0.138 83 12/21/2024
3.0.137 86 12/21/2024
3.0.136 91 12/21/2024
3.0.135 277 12/21/2024
3.0.134 173 12/21/2024
3.0.133 86 12/21/2024
3.0.132 89 12/21/2024
3.0.131 79 12/21/2024
3.0.130 234 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 163 12/20/2024
3.0.125 86 12/20/2024
3.0.124 186 12/20/2024
3.0.123 164 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 142 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 204 12/16/2024
3.0.110 286 12/10/2024
3.0.109 88 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 210 12/9/2024
3.0.104 85 12/9/2024
3.0.103 287 12/7/2024
3.0.102 111 12/6/2024
3.0.101 108 12/6/2024
3.0.100 104 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 115 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 93 11/19/2024
3.0.45 290 11/15/2024
3.0.44 136 11/14/2024
3.0.43 91 11/14/2024
3.0.42 88 11/14/2024
3.0.41 137 11/14/2024
3.0.40 105 11/14/2024
3.0.39 215 11/14/2024
3.0.38 312 11/14/2024
3.0.37 157 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 261 11/6/2024
2.1.18 332 11/1/2024
2.1.17 93 11/1/2024
2.1.16 321 11/1/2024
2.1.14 109 10/29/2024
2.1.13 258 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 260 10/22/2024
2.1.4 116 10/22/2024
2.1.3 92 10/22/2024
2.1.2 101 10/22/2024
2.1.1 121 10/22/2024