Continue 3.0.0
dotnet add package Continue --version 3.0.0
NuGet\Install-Package Continue -Version 3.0.0
<PackageReference Include="Continue" Version="3.0.0" />
<PackageVersion Include="Continue" Version="3.0.0" />
<PackageReference Include="Continue" />
paket add Continue --version 3.0.0
#r "nuget: Continue, 3.0.0"
#:package Continue@3.0.0
#addin nuget:?package=Continue&version=3.0.0
#tool nuget:?package=Continue&version=3.0.0
Continue
Continue is a small .NET library that adds strongly typed state overloads for Task.ContinueWith and CancellationToken.Register.
Instead of passing state through object and casting inside your continuation or callback, you can keep your state type-safe from call site to callback.
Features
- Strongly typed
ContinueWithoverloads forTask - Strongly typed
ContinueWithoverloads forTask<TResult> - Strongly typed
Registeroverloads forCancellationToken - Supports the most common continuation and cancellation overload shapes
- Compatible with modern .NET, .NET Standard, and .NET Framework
- AOT-friendly for supported targets
Why use it?
The built-in Task.ContinueWith and CancellationToken.Register APIs accept state as object. That works, but it usually means:
- manual casting inside continuation or callback code
- weaker compile-time safety
- less readable call sites
Continue keeps the API surface familiar while making the state parameter strongly typed.
Installation
Install the package from NuGet:
dotnet add package Continue
Or add it directly to your project file:
<ItemGroup>
<PackageReference Include="Continue" Version="3.0.0" />
</ItemGroup>
Supported targets
This package targets:
- .NET 10.0
- .NET Standard 2.1
- .NET Framework 4.8.1
Quick start
Task continuations
using System;
using System.Threading.Tasks;
using WB.Continue;
Task task = Task.CompletedTask;
var state = new RequestContext("demo");
task.ContinueWith(
static (completedTask, context) =>
{
Console.WriteLine($"Status: {completedTask.Status}");
Console.WriteLine($"Name: {context.Name}");
},
state);
Task<TResult> continuations
using System.Threading.Tasks;
using WB.Continue;
Task<int> task = Task.FromResult(42);
var state = new CalculationState(10);
Task<int> continuation = task.ContinueWith(
static (completedTask, context) => completedTask.Result + context.Offset,
state);
CancellationToken registration
using System;
using System.Threading;
using WB.Continue;
var state = new CancellationContext("operation");
var cts = new CancellationTokenSource();
cts.Token.Register(
static (context) =>
{
Console.WriteLine($"Operation cancelled: {context.Name}");
},
state);
Available overloads
Continue provides strongly typed overloads for these common patterns:
Task continuations
ContinueWith<TState>(Action<Task, TState>, TState)ContinueWith<TState>(Action<Task, TState>, TState, CancellationToken)ContinueWith<TState>(Action<Task, TState>, TState, TaskContinuationOptions)ContinueWith<TState>(Action<Task, TState>, TState, TaskScheduler)ContinueWith<TState>(Action<Task, TState>, TState, CancellationToken, TaskContinuationOptions, TaskScheduler)ContinueWith<TResult, TState>(Func<Task<TResult>, TState, TResult>, TState)ContinueWith<TResult, TState>(Func<Task<TResult>, TState, TResult>, TState, CancellationToken)ContinueWith<TResult, TState>(Func<Task<TResult>, TState, TResult>, TState, TaskContinuationOptions)ContinueWith<TResult, TState>(Func<Task<TResult>, TState, TResult>, TState, TaskScheduler)ContinueWith<TResult, TState>(Func<Task<TResult>, TState, TResult>, TState, CancellationToken, TaskContinuationOptions, TaskScheduler)ContinueWith<TResult, TState, TNewResult>(Func<Task<TResult>, TState, TNewResult>, TState)ContinueWith<TResult, TState, TNewResult>(Func<Task<TResult>, TState, TNewResult>, TState, CancellationToken)ContinueWith<TResult, TState, TNewResult>(Func<Task<TResult>, TState, TNewResult>, TState, TaskContinuationOptions)ContinueWith<TResult, TState, TNewResult>(Func<Task<TResult>, TState, TNewResult>, TState, TaskScheduler)ContinueWith<TResult, TState, TNewResult>(Func<Task<TResult>, TState, TNewResult>, TState, CancellationToken, TaskContinuationOptions, TaskScheduler)ContinueWith<TResult, TState>(Func<Task, TState, TResult>, TState)ContinueWith<TResult, TState>(Func<Task, TState, TResult>, TState, CancellationToken)ContinueWith<TResult, TState>(Func<Task, TState, TResult>, TState, TaskContinuationOptions)ContinueWith<TResult, TState>(Func<Task, TState, TResult>, TState, TaskScheduler)ContinueWith<TResult, TState>(Func<Task, TState, TResult>, TState, CancellationToken, TaskContinuationOptions, TaskScheduler)
CancellationToken registration
Register<TState>(Action<TState, CancellationToken>, TState)(.NET 6.0+)Register<TState>(Action<TState>, TState)Register<TState>(Action<TState>, TState, bool useSynchronizationContext)
Notes
TStateis constrained to reference types, matching the underlyingTaskcontinuation state model.- The package is implemented as lightweight extension methods, so there is no runtime service setup or initialization step.
Building and testing
From the solution root:
dotnet build
dotnet test
License
Licensed under the MIT License.
| 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 is compatible. 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.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| .NET Framework | net481 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.8.1
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
-
.NETStandard 2.1
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
-
net10.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.