TaskOrchestrator 1.0.2
dotnet add package TaskOrchestrator --version 1.0.2
NuGet\Install-Package TaskOrchestrator -Version 1.0.2
<PackageReference Include="TaskOrchestrator" Version="1.0.2" />
<PackageVersion Include="TaskOrchestrator" Version="1.0.2" />
<PackageReference Include="TaskOrchestrator" />
paket add TaskOrchestrator --version 1.0.2
#r "nuget: TaskOrchestrator, 1.0.2"
#:package TaskOrchestrator@1.0.2
#addin nuget:?package=TaskOrchestrator&version=1.0.2
#tool nuget:?package=TaskOrchestrator&version=1.0.2
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
TaskInfoobject:IdWeightIsAsync- In case of
OnFailure, the thrownException
๐ป 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 | Versions 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. |
-
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.