Octopus.TaskTree
1.0.1
See the version list below for details.
dotnet add package Octopus.TaskTree --version 1.0.1
NuGet\Install-Package Octopus.TaskTree -Version 1.0.1
<PackageReference Include="Octopus.TaskTree" Version="1.0.1" />
paket add Octopus.TaskTree --version 1.0.1
#r "nuget: Octopus.TaskTree, 1.0.1"
// Install Octopus.TaskTree as a Cake Addin
#addin nuget:?package=Octopus.TaskTree&version=1.0.1
// Install Octopus.TaskTree as a Cake Tool
#tool nuget:?package=Octopus.TaskTree&version=1.0.1
Octopus.TaskTree
Dotnet component that helps you to manage async
tasks in a hierarchical fashion.
There are situations that we might have to manage tasks in a tree like structure. Means, the parent task depends on child tasks to be completed in a serial or concurrent fashion. The parent task needs to show the average progress value of overall operation.
This component ITaskNode
lets you to Create a task, Set a custom asynchronous function Func<IProgressReporter, CancellationToken, Task>
for it, Create one or more child tasks and get overall progress.
You have several options that you can execute them concurrently or in series. The overall progress will be updated to parent task.
Please see below code snippet for the better understanding.
// ---------------
// Create a structure of Tasks
// ---------------
ITaskNode rootTask = new TaskNode("root");
ITaskNode childTask_1 = new TaskNode("Task-1");
ITaskNode childTask_2 = new TaskNode("Task-2");
rootTask.AddChild(childTask_1);
rootTask.AddChild(childTask_2);
// --------------
// Set actions
// --------------
childTask_1.SetAction(async (reporter, cancellationToken) => {
// Simple delay function.
reporter.ReportProgress(TaskStatus.InProgress, 10, "Started...");
await Task.Delay(1000);
reporter.ReportProgress(TaskStatus.InProgress, 100, "Finished...");
});
childTask_2.SetAction(async (reporter, cancellationToken) => {
// Simple delay function.
reporter.ReportProgress(TaskStatus.InProgress, 5, "Started...");
await Task.Delay(2500);
reporter.ReportProgress(TaskStatus.InProgress, 100, "Finished...");
});
// Before starting the execution, you need to subscribe for progress report.
rootTask.OnReporting += (sender, eventArgs) => {
eventArgs.ProgressValue; // -> this will represent the overall progress
};
// Create and pass the cancellation token
var tokenSource = new CancellationTokenSource();
cancellationToken = tokenSource.Token;
// Start the execution concurrently
rootTask.ExecuteConcurrently(cancellationToken, true);
// OR
// Start the execution in series
rootTask.ExecuteInSeries(cancellationToken, true);
Demo execution
Series execution with cancellation
Concurrent execution successful
Concurrent execution with cancellation
Please note: If
rootTask
has action set to it then the action will run after executing all child tasks in case of series execution. However in concurrent execution,rootTask
's action will also be executed along with child tasks and gets the overall progress.
Road map
This is the initial version of the component. Please raise issues if you find any. Comments, suggestions and contributions are always welcome.
Here's the list of items in backlog for the upcoming releases
- Core Component
- Wpf Sample
- Blazor Server Sample
- Syntax Enhancement on subtasks creation
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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 was computed. 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. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETCoreApp 2.1
- No dependencies.
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net5.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.