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
                    
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="Shaunebu.Common.TaskSequenceManager" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shaunebu.Common.TaskSequenceManager" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Shaunebu.Common.TaskSequenceManager" />
                    
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 Shaunebu.Common.TaskSequenceManager --version 1.0.0
                    
#r "nuget: Shaunebu.Common.TaskSequenceManager, 1.0.0"
                    
#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 Shaunebu.Common.TaskSequenceManager@1.0.0
                    
#: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=Shaunebu.Common.TaskSequenceManager&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Shaunebu.Common.TaskSequenceManager&version=1.0.0
                    
Install as a Cake Tool

πŸš€ Shaunebu.Common.TaskSequenceManager

NuGet Version

NET Support NET Support NET Support Support

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 TaskSequenceManager and 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 TaskFailed event.

  • Tasks depending on failed tasks won’t run until dependencies succeed.

  • Optional OnTaskRetry callback 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 Phase and sorted by Priority.

  • 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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