TaskOrchestrator 1.0.2

dotnet add package TaskOrchestrator --version 1.0.2
                    
NuGet\Install-Package TaskOrchestrator -Version 1.0.2
                    
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="TaskOrchestrator" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TaskOrchestrator" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="TaskOrchestrator" />
                    
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 TaskOrchestrator --version 1.0.2
                    
#r "nuget: TaskOrchestrator, 1.0.2"
                    
#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.
#:package TaskOrchestrator@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TaskOrchestrator&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=TaskOrchestrator&version=1.0.2
                    
Install as a Cake Tool

TaskOrchestrator ๐Ÿ“Š

TaskOrchestrator is a lightweight utility for managing concurrent tasks. It provides flexible Sync, Async, and Hybrid pools, each with configurable behaviors.


๐ŸŒฑ What is a Pool?

A Pool is an execution ecosystem defined by:

  • ๐Ÿ”ง Configuration (set at creation time)
  • ๐Ÿ—‚ Prioritized Queue (where tasks are stored and scheduled)

๐Ÿ’ก A Hybrid Pool is simply a wrapper that combines 1 Sync Pool and 1 Async Pool.


โš™๏ธ Pool Configuration

Each pool can be customized with:

  • Fixed Workers Workers always running, constantly executing tasks from the queue.

  • Elastic Workers

    • Spawned when all fixed workers are busy
    • Automatically disposed after a configurable idle time
    • Disabled if set to 0
  • Lifecycle Events Three hooks are available:

    • BeforeExecution<TaskInfo>?
    • AfterExecution<TaskInfo>?
    • OnFailure<TaskInfo, Exception>?

    Each event provides a TaskInfo object:

    • Id
    • Weight
    • IsAsync
    • In case of OnFailure, the thrown Exception

๐Ÿ’ป Example

var hybridPool = HybridPool.Create(
    Options.GetElasticOptions(
        2, // Workers
        5, // MaxElasticWorkers
        TimeSpan.FromSeconds(10), // 10s Idle
        (info) => Console.WriteLine($"Before Executing Task:{info.id}"), // BeforeExecution Hook
        (info) => Console.WriteLine($"After Executing Task:{info.id}"), // AfterExecution Hook
        (info, ex) => Console.WriteLine($"Task: {info.id} Just failed :( \n{ex.StackTrace}") // OnFailure Hook
    )
);

//Enqueue Sync
hybridPool.Enqueue(
    () =>
    {
        Thread.Sleep(100); // Do stuff
    }, i /*Weight*/);

//Enqueue Async
hybridPool.Enqueue(
    async () =>
    {
        await Task.Delay(100); // Do stuff
    }, i /*Weight*/);

Breakdown

  • ๐Ÿ”„ Hybrid Pool โ†’ internally holds 1 Sync Pool + 1 Async Pool
  • ๐Ÿง‘โ€๐Ÿ’ป 2 Fixed Workers per pool โ†’ always running
  • โšก 5 Elastic Workers per pool โ†’ created on demand, disposed after 10s idle
  • ๐ŸŽฏ 3 Lifecycle Events โ†’ triggered before, after, and on failure

๐Ÿš€ Motivation

This project started as a small but useful experiment in concurrency management. Itโ€™s still in early development, but the goal is to build something:

  • โœ… Solid
  • โœ… User-friendly
  • โœ… Practical

Iโ€™m still learning the Task Parallel Library (TPL) and iterating daily to improve stability, usability, and performance.


Currently working on

  • NuGet Distribution

  • GitHub Actions to learn how to CI/CD the package


๐Ÿงช Testing

TaskOrchestrator includes a comprehensive test suite with covering:

Test Coverage

  • โœ… Factory Methods - Pool creation with different configurations
  • โœ… Async Task Execution - Task enqueueing and execution
  • โœ… Sync Action Execution - Action enqueueing and execution
  • โœ… Pending Work Count - Queue monitoring and statistics
  • โœ… Elastic Workers - Dynamic worker management
  • โœ… Callback System - Lifecycle event handling
  • โœ… Concurrent Execution - Multi-threaded task processing
  • โœ… Weight Priority - Task prioritization system
  • โœ… Resource Management - Proper disposal and cleanup
  • โœ… Edge Cases - Error handling and boundary conditions
  • โœ… Options Validation - Configuration parameter validation
  • โœ… TaskInfo & TaskItem - Data structure functionality

Running Tests

cd Tests
dotnet test --verbosity normal

Test-Driven Development

The test suite ensures:

  • Correctness of the hybrid pool logic
  • Thread safety in concurrent scenarios
  • Resource management and proper cleanup
  • Configuration validation and error handling
  • Performance characteristics under load

๐Ÿ› ๏ธ Development Status

Current Version: 1.0.2

Recently Completed

  • โœ… Memory optimization with struct-based task implementation
  • โœ… Lock contention reduction with atomic operations
  • โœ… Memory leak elimination in elastic workers
  • โœ… Comprehensive benchmarking system
  • โœ… Performance validation with realistic workloads
  • โœ… Complete test suite with 57 unit tests
  • โœ… Test-driven development approach

๐Ÿ”ฎ Future Improvements

Planned features include:

  • Task-level lifecycle configuration Override global pool events for specific tasks.

  • Dynamic Task Prioritization (Aging) Prevent low-priority tasks from being starved by increasing their priority over time.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 350 9/15/2025
1.0.1 201 9/13/2025
1.0.0 435 9/10/2025 1.0.0 is deprecated because it has critical bugs.