Soenneker.ConcurrentProcessing.Executor 3.0.61

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.61                
NuGet\Install-Package Soenneker.ConcurrentProcessing.Executor -Version 3.0.61                
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.61" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.ConcurrentProcessing.Executor --version 3.0.61                
#r "nuget: Soenneker.ConcurrentProcessing.Executor, 3.0.61"                
#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.ConcurrentProcessing.Executor as a Cake Addin
#addin nuget:?package=Soenneker.ConcurrentProcessing.Executor&version=3.0.61

// Install Soenneker.ConcurrentProcessing.Executor as a Cake Tool
#tool nuget:?package=Soenneker.ConcurrentProcessing.Executor&version=3.0.61                

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.86 182 2 days ago
3.0.85 87 2 days ago
3.0.84 148 6 days ago
3.0.83 176 6 days ago
3.0.82 294 8 days ago
3.0.81 219 9 days ago
3.0.80 210 12 days ago
3.0.79 99 12 days ago
3.0.78 229 15 days ago
3.0.77 146 15 days ago
3.0.76 140 15 days ago
3.0.75 149 15 days ago
3.0.74 144 15 days ago
3.0.73 156 15 days ago
3.0.72 146 15 days ago
3.0.71 382 15 days ago
3.0.70 245 16 days ago
3.0.69 207 16 days ago
3.0.68 142 16 days ago
3.0.67 218 16 days ago
3.0.66 322 20 days ago
3.0.65 245 20 days ago
3.0.64 355 24 days ago
3.0.63 208 25 days ago
3.0.62 83 25 days ago
3.0.61 138 25 days ago
3.0.60 133 25 days ago
3.0.59 173 25 days ago
3.0.58 81 25 days ago
3.0.57 123 25 days ago
3.0.56 211 a month ago
3.0.55 74 a month ago
3.0.54 76 a month ago
3.0.53 71 a month ago
3.0.52 74 a month ago
3.0.51 157 a month ago
3.0.50 84 a month ago
3.0.49 277 a month ago
3.0.48 131 a month ago
3.0.47 134 a month ago
3.0.46 144 a month ago
3.0.45 82 a month ago
3.0.44 180 a month ago
3.0.43 154 a month ago
3.0.42 75 a month ago
3.0.41 254 a month ago
3.0.40 234 a month ago
3.0.39 179 a month ago
3.0.38 107 a month ago
3.0.37 142 a month ago
3.0.36 158 a month ago
3.0.35 84 a month ago
3.0.34 257 a month ago
3.0.33 145 a month ago
3.0.32 287 a month ago
3.0.31 385 a month ago
3.0.30 151 a month ago
3.0.29 220 a month ago
3.0.28 86 a month ago
3.0.27 309 a month ago
3.0.26 235 a month ago
3.0.25 171 a month ago
3.0.24 186 a month ago
3.0.23 296 a month ago
3.0.22 94 a month ago
3.0.21 162 a month ago
3.0.20 146 a month ago
3.0.19 211 2 months ago
3.0.18 93 2 months ago
3.0.17 272 2 months ago
3.0.16 85 2 months ago
3.0.15 148 2 months ago
3.0.14 156 2 months ago
3.0.13 89 2 months ago
3.0.12 102 2 months ago
3.0.11 93 2 months ago
3.0.10 138 2 months ago
3.0.9 148 2 months ago
3.0.8 95 2 months ago
3.0.7 94 2 months ago
3.0.6 92 2 months ago
3.0.5 87 2 months ago
3.0.4 149 2 months ago
3.0.3 216 2 months ago
3.0.2 228 2 months ago
3.0.1 217 2 months ago