Shaunebu.Common.TaskSequenceManager
1.0.0
dotnet add package Shaunebu.Common.TaskSequenceManager --version 1.0.0
NuGet\Install-Package Shaunebu.Common.TaskSequenceManager -Version 1.0.0
<PackageReference Include="Shaunebu.Common.TaskSequenceManager" Version="1.0.0" />
<PackageVersion Include="Shaunebu.Common.TaskSequenceManager" Version="1.0.0" />
<PackageReference Include="Shaunebu.Common.TaskSequenceManager" />
paket add Shaunebu.Common.TaskSequenceManager --version 1.0.0
#r "nuget: Shaunebu.Common.TaskSequenceManager, 1.0.0"
#:package Shaunebu.Common.TaskSequenceManager@1.0.0
#addin nuget:?package=Shaunebu.Common.TaskSequenceManager&version=1.0.0
#tool nuget:?package=Shaunebu.Common.TaskSequenceManager&version=1.0.0
π Shaunebu.Common.TaskSequenceManager
TaskSequenceManager is a lightweight, flexible, and cross-platform .NET library for managing sequences of asynchronous tasks with dependencies, priorities, phases, retries, and live dashboard reporting.
It works with .NET Core 3.1+ and .NET 8, without requiring MAUI, making it usable in Console, Web, or Desktop applications.
π Features
| Feature | Description |
|---|---|
| π Task Phases | Group tasks by logical phases, e.g., Initialization, Processing, Finalization. |
| β‘ Priorities | Execute tasks based on priority when multiple tasks are ready. |
| π Dependencies | Tasks can depend on other tasks; they only run after dependencies complete successfully. |
| π Retries & Failures | Automatic retries on failure with configurable max retries and delays. |
| π’ Events | Real-time events: TaskStarted, TaskCompleted, TaskFailed, ProgressChanged. |
| π Live Dashboard | Console UI or custom listener to visualize live task status per phase & priority. |
| π Progress Bar | Live percentage completion progress. |
| π Serialization | Export tasks to JSON and load them back. |
| π Dependency Graph | Export dependency graph in DOT format for visualization. |
| π¨ Color-coded output | Easy visualization of task state in console: β success, β failed, β οΈ retry, β³ pending. |
π§© Getting Started
Quick guide to integrate the library in a new project. For example:
Create a console or .NET app.
Add the NuGet package or project reference.
Instantiate
TaskSequenceManagerand define tasks.Run tasks asynchronously with
RunAsync.
π§ Configuration Options
Describe configurable properties of the manager:
MaxDegreeOfParallelismβ control concurrency.GlobalTimeoutβ set a maximum duration for the entire task sequence.TaskItem.Timeoutβ set individual task timeouts.TaskItem.MaxRetriesβ retries per task.TaskItem.Priorityβ execution order when multiple tasks are ready.TaskItem.Phaseβ logical grouping for reporting and dashboards.
π‘ Error Handling
Explain how failures are handled:
Tasks that throw exceptions can be retried automatically.
Failed tasks trigger the
TaskFailedevent.Tasks depending on failed tasks wonβt run until dependencies succeed.
Optional
OnTaskRetrycallback provides granular control per retry attempt.
π Dashboard & Reporting
Guide to create live dashboards:
Subscribe to
TaskStarted,TaskCompleted,TaskFailed,ProgressChanged.Console output or custom UI can reflect live progress.
Tasks can be grouped by
Phaseand sorted byPriority.Export task progress as JSON for further reporting.
πΎ Persistence
Explain task sequence serialization:
ToJson()β serialize current task states.LoadFromJson()β reload task sequences for resuming.DependencyGraphDot()β generate DOT graph for Graphviz visualization.
π§ͺ Testing & Debugging
Tips for testing task sequences:
Create tasks with mock actions.
Simulate failures to test retries and recovery.
Validate correct execution order respecting dependencies and priorities.
Use console dashboards for debugging.
β‘ Advanced Usage
Dynamic task generation at runtime.
Parallel execution with controlled concurrency.
Conditional task execution based on previous task results.
Integration with logging frameworks (
ILogger).
π Example Scenarios
| Scenario | Description |
|---|---|
| πΉ Setup Wizard | Execute sequential setup steps with dependencies. |
| πΉ CI/CD Pipelines | Run build/test/deploy tasks in order with retries. |
| πΉ Data Processing | Multi-step data import/transform/export pipelines. |
| πΉ Automation Scripts | Background scripts or maintenance jobs with reporting. |
π Installation
Install via NuGet:
dotnet add package Shaunebu.Common.TaskSequenceManager
β Usage Example (Console App)
using Shaunebu.Common.TaskSequenceManager;
using Shaunebu.Common.TaskSequenceManager.Models;
using System;
using System.Threading;
using System.Threading.Tasks;
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine("π TaskSequenceManager Dashboard Demo\n");
// Create the task manager
var taskManager = new TaskSequenceManager()
{
MaxDegreeOfParallelism = 2,
GlobalTimeout = TimeSpan.FromSeconds(30)
};
// Subscribe to events
taskManager.TaskStarted += t => DrawDashboard(taskManager.Tasks);
taskManager.TaskCompleted += t => DrawDashboard(taskManager.Tasks);
taskManager.TaskFailed += (t, ex) => DrawDashboard(taskManager.Tasks);
taskManager.ProgressChanged += p => DrawProgressBar(p);
// Progress bar
void DrawProgressBar(double progress)
{
const int barWidth = 40;
int filled = (int)(progress / 100 * barWidth);
Console.CursorVisible = false;
Console.Write("[");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(new string('β', filled));
Console.ResetColor();
Console.Write(new string('-', barWidth - filled));
Console.Write($"] {progress:0.##}%\r");
if (progress >= 100) Console.WriteLine();
}
// Dashboard display
void DrawDashboard(IReadOnlyList<TaskItem> tasks)
{
Console.Clear();
Console.WriteLine("=== Task Dashboard ===\n");
foreach (var t in tasks.OrderBy(t => t.Phase).ThenByDescending(t => t.Priority))
{
var status = t.IsCompleted
? t.IsSuccessful ? "β
Success" : "β Failed"
: "β³ Running / Pending";
Console.WriteLine($"[{t.Phase ?? "General"} | Priority {t.Priority}] {t.Name} - {status}");
}
Console.WriteLine("\n=====================");
}
// Add tasks
taskManager.AddTask(async token =>
{
await Task.Delay(1000, token);
Console.WriteLine("Task A executed!");
}, name: "Task A", phase: "Initialization", priority: 2);
var taskB = taskManager.AddTask(async token =>
{
await Task.Delay(1500, token);
Console.WriteLine("Task B executed!");
}, name: "Task B", phase: "Processing", priority: 1, dependencies: new[] { "Task A" });
var taskC = taskManager.AddTask(async token =>
{
await Task.Delay(500, token);
Console.WriteLine("Task C executed!");
throw new InvalidOperationException("Simulated failure");
}, name: "Task C", phase: "Processing", priority: 2, maxRetries: 2, dependencies: new[] { "Task A" });
// Retry event
taskC.OnTaskRetry = (t, attempt, ex) =>
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"β οΈ {t.Name} retry {attempt} due to: {ex.Message}");
Console.ResetColor();
};
taskManager.AddTask(async token =>
{
await Task.Delay(700, token);
Console.WriteLine("Task D executed!");
}, name: "Task D", phase: "Finalization", priority: 1, dependencies: new[] { "Task B", "Task C" });
// Run all tasks
using var cts = new CancellationTokenSource();
await taskManager.RunAsync(cts.Token);
// Final dashboard
DrawDashboard(taskManager.Tasks);
// Export tasks JSON
var json = taskManager.ToJson();
Console.WriteLine("\nπ Task sequence JSON:");
Console.WriteLine(json);
// Export dependency graph
var dotGraph = taskManager.DependencyGraphDot();
Console.WriteLine("\nπ Dependency Graph DOT:");
Console.WriteLine(dotGraph);
π Notes
Designed for cross-platform use without MAUI dependencies.
Supports parallel execution via
MaxDegreeOfParallelism.Handles task failures, timeouts, and automatic retries.
Use Phases and Priorities for building dashboards and reporting.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
| .NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.Extensions.Logging (>= 9.0.9)
- Newtonsoft.Json (>= 13.0.4)
-
net8.0
- Microsoft.Extensions.Logging (>= 9.0.9)
- Newtonsoft.Json (>= 13.0.4)
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.0 | 162 | 10/21/2025 |