Soenneker.Utils.RateLimiting.Executor 3.0.106

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

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

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.206 110 1/3/2025
3.0.205 68 1/3/2025
3.0.204 73 1/3/2025
3.0.203 56 1/3/2025
3.0.202 88 1/2/2025
3.0.201 48 1/2/2025
3.0.200 43 1/2/2025
3.0.199 83 1/2/2025
3.0.198 44 1/2/2025
3.0.197 47 1/2/2025
3.0.196 180 1/1/2025
3.0.195 106 1/1/2025
3.0.194 81 1/1/2025
3.0.193 95 1/1/2025
3.0.192 144 1/1/2025
3.0.191 79 1/1/2025
3.0.190 83 1/1/2025
3.0.189 94 12/31/2024
3.0.188 82 12/31/2024
3.0.187 85 12/31/2024
3.0.186 86 12/31/2024
3.0.185 79 12/31/2024
3.0.184 124 12/31/2024
3.0.183 91 12/31/2024
3.0.182 245 12/31/2024
3.0.181 72 12/31/2024
3.0.180 213 12/31/2024
3.0.179 135 12/31/2024
3.0.178 77 12/31/2024
3.0.177 78 12/31/2024
3.0.176 76 12/31/2024
3.0.175 68 12/31/2024
3.0.174 101 12/30/2024
3.0.173 338 12/28/2024
3.0.172 98 12/28/2024
3.0.171 137 12/27/2024
3.0.170 80 12/27/2024
3.0.169 408 12/24/2024
3.0.168 177 12/24/2024
3.0.167 107 12/24/2024
3.0.166 85 12/24/2024
3.0.165 167 12/24/2024
3.0.164 75 12/24/2024
3.0.163 167 12/24/2024
3.0.162 69 12/24/2024
3.0.161 112 12/24/2024
3.0.160 87 12/23/2024
3.0.159 144 12/23/2024
3.0.158 158 12/23/2024
3.0.157 82 12/23/2024
3.0.156 251 12/23/2024
3.0.155 97 12/23/2024
3.0.154 240 12/22/2024
3.0.153 81 12/22/2024
3.0.152 78 12/22/2024
3.0.151 191 12/22/2024
3.0.150 85 12/22/2024
3.0.149 80 12/22/2024
3.0.148 75 12/22/2024
3.0.147 259 12/22/2024
3.0.146 82 12/22/2024
3.0.145 88 12/22/2024
3.0.144 80 12/22/2024
3.0.143 245 12/21/2024
3.0.142 80 12/21/2024
3.0.141 91 12/21/2024
3.0.140 76 12/21/2024
3.0.139 81 12/21/2024
3.0.138 74 12/21/2024
3.0.137 77 12/21/2024
3.0.136 82 12/21/2024
3.0.135 267 12/21/2024
3.0.134 163 12/21/2024
3.0.133 77 12/21/2024
3.0.132 80 12/21/2024
3.0.131 70 12/21/2024
3.0.130 224 12/21/2024
3.0.129 78 12/21/2024
3.0.128 128 12/20/2024
3.0.127 72 12/20/2024
3.0.126 154 12/20/2024
3.0.125 77 12/20/2024
3.0.124 178 12/20/2024
3.0.123 153 12/20/2024
3.0.122 81 12/20/2024
3.0.121 155 12/20/2024
3.0.120 179 12/19/2024
3.0.119 153 12/19/2024
3.0.118 87 12/19/2024
3.0.117 133 12/19/2024
3.0.116 80 12/18/2024
3.0.115 128 12/18/2024
3.0.114 185 12/17/2024
3.0.113 97 12/17/2024
3.0.112 60 12/17/2024
3.0.111 196 12/16/2024
3.0.110 280 12/10/2024
3.0.109 81 12/10/2024
3.0.108 161 12/10/2024
3.0.107 83 12/9/2024
3.0.106 166 12/9/2024
3.0.105 198 12/9/2024
3.0.104 79 12/9/2024
3.0.103 281 12/7/2024
3.0.102 105 12/6/2024
3.0.101 96 12/6/2024
3.0.100 98 12/6/2024
3.0.99 101 12/6/2024
3.0.97 128 12/6/2024
3.0.96 109 12/6/2024
3.0.95 84 12/6/2024
3.0.94 86 12/6/2024
3.0.93 87 12/6/2024
3.0.92 87 12/6/2024
3.0.91 122 12/6/2024
3.0.90 115 12/5/2024
3.0.89 111 12/5/2024
3.0.88 665 12/5/2024
3.0.87 126 12/5/2024
3.0.86 130 12/5/2024
3.0.85 175 12/5/2024
3.0.84 109 12/4/2024
3.0.83 134 12/4/2024
3.0.82 190 12/4/2024
3.0.81 178 12/4/2024
3.0.80 160 12/4/2024
3.0.79 89 12/3/2024
3.0.78 183 12/3/2024
3.0.77 184 12/3/2024
3.0.76 143 12/3/2024
3.0.75 77 12/3/2024
3.0.74 130 12/3/2024
3.0.73 74 12/3/2024
3.0.72 346 12/2/2024
3.0.71 136 12/2/2024
3.0.70 156 12/2/2024
3.0.69 81 12/2/2024
3.0.68 153 12/2/2024
3.0.67 203 12/1/2024
3.0.66 83 12/1/2024
3.0.65 241 12/1/2024
3.0.64 120 12/1/2024
3.0.63 192 11/29/2024
3.0.62 160 11/29/2024
3.0.61 249 11/21/2024
3.0.60 99 11/21/2024
3.0.59 249 11/20/2024
3.0.58 85 11/20/2024
3.0.57 113 11/20/2024
3.0.56 88 11/20/2024
3.0.55 88 11/20/2024
3.0.54 100 11/20/2024
3.0.53 95 11/19/2024
3.0.52 89 11/19/2024
3.0.51 85 11/19/2024
3.0.50 371 11/19/2024
3.0.49 79 11/19/2024
3.0.48 298 11/19/2024
3.0.47 84 11/19/2024
3.0.46 88 11/19/2024
3.0.45 283 11/15/2024
3.0.44 128 11/14/2024
3.0.43 83 11/14/2024
3.0.42 82 11/14/2024
3.0.41 130 11/14/2024
3.0.40 96 11/14/2024
3.0.39 208 11/14/2024
3.0.38 305 11/14/2024
3.0.37 148 11/14/2024
3.0.36 85 11/14/2024
3.0.35 85 11/14/2024
3.0.34 130 11/14/2024
3.0.33 86 11/14/2024
3.0.32 186 11/14/2024
2.1.31 288 11/13/2024
2.1.30 175 11/13/2024
2.1.29 248 11/13/2024
2.1.28 138 11/12/2024
2.1.27 81 11/12/2024
2.1.26 641 11/9/2024
2.1.25 173 11/9/2024
2.1.24 331 11/8/2024
2.1.23 91 11/8/2024
2.1.22 86 11/8/2024
2.1.21 282 11/8/2024
2.1.20 224 11/8/2024
2.1.19 251 11/6/2024
2.1.18 323 11/1/2024
2.1.17 83 11/1/2024
2.1.16 311 11/1/2024
2.1.14 97 10/29/2024
2.1.13 248 10/29/2024
2.1.12 134 10/29/2024
2.1.11 403 10/29/2024
2.1.10 248 10/28/2024
2.1.9 84 10/28/2024
2.1.8 117 10/28/2024
2.1.7 348 10/26/2024
2.1.6 110 10/26/2024
2.1.5 255 10/22/2024
2.1.4 111 10/22/2024
2.1.3 88 10/22/2024
2.1.2 95 10/22/2024
2.1.1 115 10/22/2024