NetFramework.Tasks.Management
1.0.2
See the version list below for details.
dotnet add package NetFramework.Tasks.Management --version 1.0.2
NuGet\Install-Package NetFramework.Tasks.Management -Version 1.0.2
<PackageReference Include="NetFramework.Tasks.Management" Version="1.0.2" />
<PackageVersion Include="NetFramework.Tasks.Management" Version="1.0.2" />
<PackageReference Include="NetFramework.Tasks.Management" />
paket add NetFramework.Tasks.Management --version 1.0.2
#r "nuget: NetFramework.Tasks.Management, 1.0.2"
#:package NetFramework.Tasks.Management@1.0.2
#addin nuget:?package=NetFramework.Tasks.Management&version=1.0.2
#tool nuget:?package=NetFramework.Tasks.Management&version=1.0.2
NetTaskManagement
A .NET Standard 2.0 library for Task Parallel Library (TPL) orchestration with Dependency Injection support.
Tasks are identified by string key and managed through a status-based API — no raw Task objects exposed to callers. The library handles the full task lifecycle: register → start → cancel → check completion → delete, and exposes an append-only observability queue that captures disposal metadata for external monitoring.
Packages
| Package | NuGet |
|---|---|
NetFramework.Tasks.Management |
Core implementation |
NetFramework.Tasks.Management.Abstractions |
Interfaces, enums, and models only |
Installation
dotnet add package NetFramework.Tasks.Management
If you only need the ITaskManagement contract (e.g. in a project that wires up DI but doesn't consume the implementation directly):
dotnet add package NetFramework.Tasks.Management.Abstractions
Quick start
Register the service
services.AddTaskManagement();
Inject and use ITaskManagement
public class MyService
{
private readonly ITaskManagement _tasks;
public MyService(ITaskManagement tasks) => _tasks = tasks;
public void RunJob(string jobName)
{
var cts = new CancellationTokenSource();
_tasks.RegisterTask(jobName, state =>
{
var token = ((CancellationTokenSource)state).Token;
while (!token.IsCancellationRequested)
{
// do work
}
}, cts);
_tasks.StartTask(jobName);
}
public void CancelJob(string jobName) => _tasks.CancelTask(jobName);
}
API reference
All methods return TaskManagementStatus — an enum value instead of throwing exceptions for expected outcomes.
| Method | Description |
|---|---|
RegisterTask(name, action, cts) |
Registers a new task by name |
StartTask(name) |
Starts a previously registered task |
CancelTask(name) |
Requests cancellation via the task's CancellationTokenSource |
CheckTaskStatusCompleted(name, retry, timeoutMs) |
Polls until the task completes or the timeout elapses |
DeleteTask(name, sendToQueue) |
Disposes the task and removes it from the registry; optionally enqueues disposal metadata |
DequeueTaskDisposedDataModel(out model) |
Dequeues one disposal record for external monitoring |
GetTasksStatus() |
Returns a snapshot Dictionary<string, TaskStatus> of all live tasks |
CancelAllTasks(except, ref failed) |
Cancels all tasks, optionally skipping a list of names |
CheckAllTaskStatusCompleted(except, ref statuses, retry, timeoutMs) |
Polls completion for all tasks, optionally skipping a list of names |
GetCancellationTokenSource(name, ref cts) |
Retrieves the CancellationTokenSource for a registered task |
Status enum highlights
| Status | Meaning |
|---|---|
Added |
Task registered successfully |
Started |
Task started successfully |
Canceled |
Cancellation requested |
Completed |
Task reached a completion state |
NotCompleted |
Polling timed out before completion |
Deleted |
Task disposed and removed |
TaskNotFound |
No task registered under that name |
AlreadyRegistered |
A task with that name already exists |
Observability queue
When DeleteTask(name, sendToQueue: true) is called, a TaskDisposedDataModel record (task name, id, final status, disposed flag) is appended to an internal ConcurrentQueue. Dequeue and forward it to your logging or monitoring platform however you like:
if (_tasks.DequeueTaskDisposedDataModel(out var record) == TaskManagementStatus.ObjectInfoDequeued)
{
logger.LogInformation("Task {Name} (id={Id}) finished with status {Status}",
record.TaskName, record.TaskId, record.TaskStatus);
}
Benchmarks
Performance is tracked automatically on every push to main and published as interactive charts:
Benchmarks cover:
LifecycleBenchmarks— individual lifecycle stages: Register, Start, Cancel, Delete, and full end-to-endGetTasksStatusBenchmarks— dictionary snapshot cost at 1, 10, and 50 tasksCancelAllTasksBenchmarks—Parallel.ForEachcancellation fan-out at 1, 10, and 50 tasks
All benchmarks run on net8.0, net9.0, and net10.0 with [MemoryDiagnoser] enabled (reports allocated bytes per operation).
To run locally (Release mode required):
dotnet run -c Release -f net8.0 --project benchmarks/NetFramework.Tasks.Management.Benchmarks/ -- --filter '*'
See benchmarks/README.md for full run instructions and filter examples.
Examples
| Example | Description |
|---|---|
| Financial Order Processing | Multi-threaded market order pipeline — producer, 5 trading desk workers, live monitor, graceful shutdown, and observability queue drain |
License
MIT © Jose Luis Guerra Infante
| 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 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. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.1)
- NetFramework.Tasks.Management.Abstractions (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.