Soenneker.Utils.RateLimiting.Executor 3.0.310

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

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

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.317 0 2/21/2025
3.0.316 0 2/21/2025
3.0.315 129 2/19/2025
3.0.314 91 2/19/2025
3.0.313 93 2/19/2025
3.0.312 67 2/18/2025
3.0.311 194 2/18/2025
3.0.310 121 2/18/2025
3.0.309 63 2/18/2025
3.0.308 401 2/14/2025
3.0.307 65 2/14/2025
3.0.306 141 2/13/2025
3.0.305 371 2/12/2025
3.0.304 87 2/12/2025
3.0.303 157 2/12/2025
3.0.302 158 2/11/2025
3.0.301 151 2/11/2025
3.0.300 276 2/11/2025
3.0.299 215 2/11/2025
3.0.298 66 2/11/2025
3.0.297 152 2/11/2025
3.0.296 168 2/10/2025
3.0.295 117 2/10/2025
3.0.294 166 2/10/2025
3.0.293 63 2/10/2025
3.0.292 66 2/10/2025
3.0.291 356 2/9/2025
3.0.290 88 2/8/2025
3.0.289 63 2/8/2025
3.0.288 67 2/8/2025
3.0.287 72 2/8/2025
3.0.286 289 2/8/2025
3.0.285 87 2/7/2025
3.0.284 119 2/7/2025
3.0.283 236 2/7/2025
3.0.282 70 2/7/2025
3.0.281 68 2/7/2025
3.0.280 67 2/7/2025
3.0.279 111 2/7/2025
3.0.278 63 2/7/2025
3.0.277 75 2/7/2025
3.0.276 281 2/6/2025
3.0.275 181 2/5/2025
3.0.274 137 2/5/2025
3.0.273 74 2/5/2025
3.0.272 85 2/5/2025
3.0.271 216 2/5/2025
3.0.270 79 2/5/2025
3.0.269 73 2/5/2025
3.0.268 432 1/28/2025
3.0.267 39 1/28/2025
3.0.266 51 1/28/2025
3.0.265 257 1/27/2025
3.0.264 41 1/27/2025
3.0.263 34 1/27/2025
3.0.262 34 1/27/2025
3.0.261 85 1/27/2025
3.0.260 48 1/27/2025
3.0.259 214 1/26/2025
3.0.258 48 1/26/2025
3.0.257 47 1/26/2025
3.0.256 32 1/26/2025
3.0.255 120 1/25/2025
3.0.254 148 1/25/2025
3.0.253 39 1/25/2025
3.0.252 38 1/25/2025
3.0.251 34 1/25/2025
3.0.250 124 1/25/2025
3.0.249 226 1/24/2025
3.0.248 35 1/24/2025
3.0.247 105 1/24/2025
3.0.246 94 1/24/2025
3.0.245 175 1/24/2025
3.0.244 118 1/23/2025
3.0.243 240 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 259 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 550 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,783 1/14/2025
3.0.226 35 1/14/2025
3.0.225 44 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 66 1/13/2025
3.0.219 55 1/13/2025
3.0.218 148 1/12/2025
3.0.217 115 1/11/2025
3.0.216 93 1/11/2025
3.0.215 105 1/11/2025
3.0.214 70 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 90 12/31/2024
3.0.187 93 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 244 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 88 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 88 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 152 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 199 12/22/2024
3.0.150 91 12/22/2024
3.0.149 88 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 88 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 84 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 90 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 137 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 89 12/20/2024
3.0.121 161 12/20/2024
3.0.120 187 12/19/2024
3.0.119 162 12/19/2024
3.0.118 93 12/19/2024
3.0.117 139 12/19/2024
3.0.116 88 12/18/2024
3.0.115 134 12/18/2024
3.0.114 191 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 168 12/10/2024
3.0.107 89 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 287 12/7/2024
3.0.102 109 12/6/2024
3.0.101 102 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 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