Soenneker.ConcurrentProcessing.Executor 3.0.155

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.ConcurrentProcessing.Executor --version 3.0.155
                    
NuGet\Install-Package Soenneker.ConcurrentProcessing.Executor -Version 3.0.155
                    
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.ConcurrentProcessing.Executor" Version="3.0.155" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.ConcurrentProcessing.Executor" Version="3.0.155" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.ConcurrentProcessing.Executor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.ConcurrentProcessing.Executor --version 3.0.155
                    
#r "nuget: Soenneker.ConcurrentProcessing.Executor, 3.0.155"
                    
#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.
#addin nuget:?package=Soenneker.ConcurrentProcessing.Executor&version=3.0.155
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.ConcurrentProcessing.Executor&version=3.0.155
                    
Install as a Cake Tool

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.ConcurrentProcessing.Executor

This executor efficiently handles multiple tasks with controlled concurrency. It is ideal for managing parallel execution of tasks while ensuring that no more than a specified number of tasks run simultaneously.

Key Features

  • Concurrent Execution: Limits the number of concurrent tasks to prevent overloading.
  • Failure Handling with Retry Logic: Automatically retries failed tasks with exponential backoff.
  • Async Semaphore: Uses a non-blocking semaphore to control concurrency and ensure thread safety.
  • CancellationToken support for task cancellation.

⚠️ Note:

  • This is not a background processor. It only manages concurrency for tasks that are provided during execution.

Installation

dotnet add package Soenneker.ConcurrentProcessing.Executor

Example: Executing Multiple Tasks with Concurrency Control

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Soenneker.ConcurrentProcessing.Executor;

public class Program
{
    public static async Task Main(string[] args)
    {
        var executor = new ConcurrentProcessingExecutor(maxConcurrency: 3);

        var tasks = new List<Func<CancellationToken, ValueTask>>
        {
            async (ct) => { 
                Console.WriteLine("Task 1 started"); 
                await Task.Delay(500, ct); 
                Console.WriteLine("Task 1 completed"); 
            },

            async (ct) => { 
                Console.WriteLine("Task 2 started"); 
                await Task.Delay(300, ct); 
                Console.WriteLine("Task 2 completed"); 
            },

            async (ct) => { 
                Console.WriteLine("Task 3 started"); 
                await Task.Delay(700, ct); 
                Console.WriteLine("Task 3 completed");
            },

            async (ct) => { 
                Console.WriteLine("Task 4 started"); 
                await Task.Delay(400, ct); 
                Console.WriteLine("Task 4 completed"); 
            }
        };

        await executor.Execute(tasks);
    }
}

Console Output

Task 1 started
Task 2 started
Task 3 started
Task 1 completed
Task 4 started
Task 2 completed
Task 3 completed
Task 4 completed
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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.ConcurrentProcessing.Executor:

Package Downloads
Soenneker.Cosmos.Repository

A data persistence abstraction layer for Cosmos DB

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.171 379 5 days ago
3.0.170 174 5 days ago
3.0.169 219 5 days ago
3.0.168 952 16 days ago
3.0.167 168 16 days ago
3.0.166 73 16 days ago
3.0.165 69 16 days ago
3.0.164 162 16 days ago
3.0.163 1,041 a month ago
3.0.162 356 a month ago
3.0.161 313 a month ago
3.0.160 352 a month ago
3.0.159 600 2 months ago
3.0.158 194 2 months ago
3.0.157 134 2 months ago
3.0.156 198 2 months ago
3.0.155 798 2 months ago
3.0.154 212 2 months ago
3.0.153 138 2 months ago
3.0.152 175 2 months ago
3.0.151 614 2 months ago
3.0.150 272 2 months ago
3.0.149 685 2 months ago
3.0.148 196 2 months ago
3.0.147 135 2 months ago
3.0.146 139 2 months ago
3.0.145 398 2 months ago
3.0.144 141 2 months ago
3.0.143 129 2 months ago
3.0.142 133 2 months ago
3.0.141 138 2 months ago
3.0.140 556 2 months ago
3.0.139 1,345 3 months ago
3.0.138 199 3 months ago
3.0.137 164 3 months ago
3.0.136 155 3 months ago
3.0.135 156 3 months ago
3.0.134 154 3 months ago
3.0.133 153 3 months ago
3.0.132 463 3 months ago
3.0.131 295 3 months ago
3.0.130 251 3 months ago
3.0.129 345 3 months ago
3.0.128 316 3 months ago
3.0.127 269 3 months ago
3.0.126 252 3 months ago
3.0.125 419 3 months ago
3.0.124 263 3 months ago
3.0.123 369 3 months ago
3.0.122 188 3 months ago
3.0.121 145 3 months ago
3.0.120 155 3 months ago
3.0.119 145 3 months ago
3.0.118 148 3 months ago
3.0.117 170 3 months ago
3.0.116 137 3 months ago
3.0.115 131 3 months ago
3.0.114 105 3 months ago
3.0.113 90 3 months ago
3.0.112 91 3 months ago
3.0.111 111 3 months ago
3.0.110 105 3 months ago
3.0.109 103 3 months ago
3.0.108 96 3 months ago
3.0.107 71 3 months ago
3.0.106 85 3 months ago
3.0.105 84 3 months ago
3.0.104 84 3 months ago
3.0.103 80 3 months ago
3.0.102 88 3 months ago
3.0.101 88 3 months ago
3.0.100 87 3 months ago
3.0.99 83 3 months ago
3.0.98 95 3 months ago
3.0.97 1,977 3 months ago
3.0.96 420 3 months ago
3.0.95 270 3 months ago
3.0.94 193 3 months ago
3.0.93 394 3 months ago
3.0.92 194 3 months ago
3.0.91 346 3 months ago
3.0.90 219 3 months ago
3.0.89 211 3 months ago
3.0.88 90 3 months ago
3.0.87 133 3 months ago
3.0.86 711 4 months ago
3.0.85 528 4 months ago
3.0.84 199 4 months ago
3.0.83 219 4 months ago
3.0.82 327 4 months ago
3.0.81 242 4 months ago
3.0.80 224 4 months ago
3.0.79 115 4 months ago
3.0.78 248 4 months ago
3.0.77 163 4 months ago
3.0.76 158 4 months ago
3.0.75 172 4 months ago
3.0.74 162 4 months ago
3.0.73 181 4 months ago
3.0.72 164 4 months ago
3.0.71 405 4 months ago
3.0.70 260 4 months ago
3.0.69 230 4 months ago
3.0.68 159 4 months ago
3.0.67 239 4 months ago
3.0.66 350 4 months ago
3.0.65 263 4 months ago
3.0.64 376 4 months ago
3.0.63 232 4 months ago
3.0.62 104 4 months ago
3.0.61 162 4 months ago
3.0.60 153 4 months ago
3.0.59 193 4 months ago
3.0.58 102 4 months ago
3.0.57 149 4 months ago
3.0.56 229 4 months ago
3.0.55 100 4 months ago
3.0.54 95 4 months ago
3.0.53 96 4 months ago
3.0.52 92 4 months ago
3.0.51 174 4 months ago
3.0.50 99 4 months ago
3.0.49 300 5 months ago
3.0.48 151 5 months ago
3.0.47 153 5 months ago
3.0.46 165 5 months ago
3.0.45 102 5 months ago
3.0.44 202 5 months ago
3.0.43 172 5 months ago
3.0.42 96 5 months ago
3.0.41 275 5 months ago
3.0.40 253 5 months ago
3.0.39 198 5 months ago
3.0.38 123 5 months ago
3.0.37 164 5 months ago
3.0.36 179 5 months ago
3.0.35 107 5 months ago
3.0.34 273 5 months ago
3.0.33 164 5 months ago
3.0.32 311 5 months ago
3.0.31 402 5 months ago
3.0.30 172 5 months ago
3.0.29 239 5 months ago
3.0.28 105 5 months ago
3.0.27 330 5 months ago
3.0.26 252 5 months ago
3.0.25 191 5 months ago
3.0.24 210 5 months ago
3.0.23 317 5 months ago
3.0.22 109 5 months ago
3.0.21 182 5 months ago
3.0.20 164 5 months ago
3.0.19 228 5 months ago
3.0.18 113 5 months ago
3.0.17 291 5 months ago
3.0.16 102 5 months ago
3.0.15 166 5 months ago
3.0.14 172 5 months ago
3.0.13 107 5 months ago
3.0.12 122 5 months ago
3.0.11 107 5 months ago
3.0.10 152 5 months ago
3.0.9 166 5 months ago
3.0.8 109 5 months ago
3.0.7 106 5 months ago
3.0.6 112 5 months ago
3.0.5 101 5 months ago
3.0.4 164 5 months ago
3.0.3 233 5 months ago
3.0.2 246 5 months ago
3.0.1 237 5 months ago