Soenneker.ConcurrentProcessing.Executor 3.0.33

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.33
                    
NuGet\Install-Package Soenneker.ConcurrentProcessing.Executor -Version 3.0.33
                    
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.33" />
                    
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.33" />
                    
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.33
                    
#r "nuget: Soenneker.ConcurrentProcessing.Executor, 3.0.33"
                    
#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.33
                    
Install Soenneker.ConcurrentProcessing.Executor as a Cake Addin
#tool nuget:?package=Soenneker.ConcurrentProcessing.Executor&version=3.0.33
                    
Install Soenneker.ConcurrentProcessing.Executor 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. 
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.139 93 19 hours ago
3.0.138 61 21 hours ago
3.0.137 45 21 hours ago
3.0.136 38 21 hours ago
3.0.135 34 a day ago
3.0.134 33 a day ago
3.0.133 39 a day ago
3.0.132 198 a day ago
3.0.131 121 a day ago
3.0.130 118 a day ago
3.0.129 195 2 days ago
3.0.128 171 2 days ago
3.0.127 147 2 days ago
3.0.126 131 2 days ago
3.0.125 267 2 days ago
3.0.124 133 2 days ago
3.0.123 233 2 days ago
3.0.122 80 2 days ago
3.0.121 43 2 days ago
3.0.120 48 3 days ago
3.0.119 39 3 days ago
3.0.118 44 3 days ago
3.0.117 50 3 days ago
3.0.116 42 3 days ago
3.0.115 44 3 days ago
3.0.114 49 3 days ago
3.0.113 41 4 days ago
3.0.112 39 4 days ago
3.0.111 53 4 days ago
3.0.110 47 4 days ago
3.0.109 43 4 days ago
3.0.108 44 4 days ago
3.0.107 46 4 days ago
3.0.106 50 4 days ago
3.0.105 47 4 days ago
3.0.104 52 4 days ago
3.0.103 43 4 days ago
3.0.102 50 5 days ago
3.0.101 54 5 days ago
3.0.100 57 5 days ago
3.0.99 52 5 days ago
3.0.98 65 5 days ago
3.0.97 1,626 6 days ago
3.0.96 361 8 days ago
3.0.95 229 8 days ago
3.0.94 168 8 days ago
3.0.93 346 9 days ago
3.0.92 176 9 days ago
3.0.91 313 9 days ago
3.0.90 197 9 days ago
3.0.89 191 11 days ago
3.0.88 77 11 days ago
3.0.87 115 11 days ago
3.0.86 690 15 days ago
3.0.85 509 15 days ago
3.0.84 172 19 days ago
3.0.83 200 20 days ago
3.0.82 306 22 days ago
3.0.81 225 22 days ago
3.0.80 214 25 days ago
3.0.79 105 a month ago
3.0.78 234 a month ago
3.0.77 152 a month ago
3.0.76 145 a month ago
3.0.75 155 a month ago
3.0.74 149 a month ago
3.0.73 161 a month ago
3.0.72 151 a month ago
3.0.71 388 a month ago
3.0.70 250 a month ago
3.0.69 212 a month ago
3.0.68 147 a month ago
3.0.67 224 a month ago
3.0.66 330 a month ago
3.0.65 250 a month ago
3.0.64 361 a month ago
3.0.63 213 a month ago
3.0.62 89 a month ago
3.0.61 144 a month ago
3.0.60 140 a month ago
3.0.59 182 a month ago
3.0.58 86 a month ago
3.0.57 128 a month ago
3.0.56 215 a month ago
3.0.55 78 a month ago
3.0.54 80 a month ago
3.0.53 75 a month ago
3.0.52 79 a month ago
3.0.51 161 a month ago
3.0.50 88 a month ago
3.0.49 282 a month ago
3.0.48 136 a month ago
3.0.47 139 a month ago
3.0.46 149 a month ago
3.0.45 87 2 months ago
3.0.44 185 2 months ago
3.0.43 159 2 months ago
3.0.42 80 2 months ago
3.0.41 259 2 months ago
3.0.40 239 2 months ago
3.0.39 184 2 months ago
3.0.38 113 2 months ago
3.0.37 148 2 months ago
3.0.36 164 2 months ago
3.0.35 91 2 months ago
3.0.34 263 2 months ago
3.0.33 152 2 months ago
3.0.32 294 2 months ago
3.0.31 392 2 months ago
3.0.30 158 2 months ago
3.0.29 227 2 months ago
3.0.28 93 2 months ago
3.0.27 316 2 months ago
3.0.26 242 2 months ago
3.0.25 177 2 months ago
3.0.24 193 2 months ago
3.0.23 302 2 months ago
3.0.22 100 2 months ago
3.0.21 168 2 months ago
3.0.20 152 2 months ago
3.0.19 217 2 months ago
3.0.18 99 2 months ago
3.0.17 278 2 months ago
3.0.16 91 2 months ago
3.0.15 154 2 months ago
3.0.14 162 2 months ago
3.0.13 94 2 months ago
3.0.12 113 2 months ago
3.0.11 98 2 months ago
3.0.10 143 2 months ago
3.0.9 153 2 months ago
3.0.8 100 2 months ago
3.0.7 98 2 months ago
3.0.6 96 2 months ago
3.0.5 91 2 months ago
3.0.4 153 2 months ago
3.0.3 220 2 months ago
3.0.2 232 2 months ago
3.0.1 221 2 months ago