Net.Utils.TaskManager
1.0.0
See the version list below for details.
dotnet add package Net.Utils.TaskManager --version 1.0.0
NuGet\Install-Package Net.Utils.TaskManager -Version 1.0.0
<PackageReference Include="Net.Utils.TaskManager" Version="1.0.0" />
paket add Net.Utils.TaskManager --version 1.0.0
#r "nuget: Net.Utils.TaskManager, 1.0.0"
// Install Net.Utils.TaskManager as a Cake Addin #addin nuget:?package=Net.Utils.TaskManager&version=1.0.0 // Install Net.Utils.TaskManager as a Cake Tool #tool nuget:?package=Net.Utils.TaskManager&version=1.0.0
Net.Utils.TaskManager
C# library offering an advanced asynchronous Task Manager optimized for handling concurrent task execution with a focus on dynamic task queuing. It is specifically designed to allow runtime addition of tasks, ensuring seamless integration of newly discovered tasks into the ongoing execution process. The library demonstrates effective use of Task parallelism and continuation in .NET.
Features
- Concurrent and asynchronous task execution.
- Ability to add and handle tasks dynamically after the task manager has started.
- Efficient handling of tasks with continuation support.
- Extensible design with
IAddTask
interface for customizable task addition.
Handling of Dynamic Tasks
One of the key features of Net.Utils.TaskManager
is its ability to handle tasks that are added dynamically, even after the task execution has started. This is useful in scenarios where a task's execution might lead to the discovery of new tasks that need to be run in the same cycle.
Initialization
To begin using the Net.Utils.TaskManager
, you must first create an instance of the TaskManager
class:
var taskManager = new TaskManager();
Alternatively, if you already have a collection of tasks to execute, you can initialize the TaskManager
with them:
var initialTasks = new List<Task> { /* your tasks here */ };
var taskManager = new TaskManager(initialTasks);
Methods
The TaskManager
class provides the following methods:
AddTask(Task task)
: Adds a single task to the manager.AddRange(IEnumerable<Task> tasks)
: Adds a collection of tasks to the manager.StartAsync()
: Starts executing the tasks asynchronously.AwaitFinish()
: Awaits the completion of all tasks.
AddTask
// Adds a new task to the manager
taskManager.AddTask(new Task(() => DoWork()));
AddRange
// Adds a range of tasks at once
taskManager.AddRange(new List<Task> { task1, task2, task3 });
StartAsync
// Starts the task manager and executes all tasks
await taskManager.StartAsync();
AwaitFinish
// Waits for all tasks to complete
await taskManager.AwaitFinish();
IAddTask
The IAddTask
interface is designed to allow for extensibility in task management. By implementing this interface, developers can customize how tasks are added to the manager, enabling integration with different task sources or adding additional logic when tasks are registered.
public class CustomTaskAdder : IAddTask
{
private readonly TaskManager manager;
public CustomTaskAdder(TaskManager taskManager)
{
manager = taskManager;
}
public void AddTask(Task task)
{
// Custom logic before adding a task
manager.AddTask(task);
}
public void AddRange(IEnumerable<Task> tasks)
{
// Custom logic before adding a range of tasks
manager.AddRange(tasks);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Net.Utils.TaskManager:
Package | Downloads |
---|---|
DownloaderV3
The core module for managing blockchain data downloading and event processing in the DownloaderV3 system. |
GitHub repositories
This package is not used by any popular GitHub repositories.