Continue 3.0.0

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

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 ContinueWith overloads for Task
  • Strongly typed ContinueWith overloads for Task<TResult>
  • Strongly typed Register overloads for CancellationToken
  • 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

  • TState is constrained to reference types, matching the underlying Task continuation 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 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. 
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
3.0.0 130 7/17/2026
2.0.0 103 7/16/2026
1.0.0 125 7/16/2026