Soenneker.Extensions.CancellationTokens
4.0.25
Prefix Reserved
dotnet add package Soenneker.Extensions.CancellationTokens --version 4.0.25
NuGet\Install-Package Soenneker.Extensions.CancellationTokens -Version 4.0.25
<PackageReference Include="Soenneker.Extensions.CancellationTokens" Version="4.0.25" />
<PackageVersion Include="Soenneker.Extensions.CancellationTokens" Version="4.0.25" />
<PackageReference Include="Soenneker.Extensions.CancellationTokens" />
paket add Soenneker.Extensions.CancellationTokens --version 4.0.25
#r "nuget: Soenneker.Extensions.CancellationTokens, 4.0.25"
#:package Soenneker.Extensions.CancellationTokens@4.0.25
#addin nuget:?package=Soenneker.Extensions.CancellationTokens&version=4.0.25
#tool nuget:?package=Soenneker.Extensions.CancellationTokens&version=4.0.25
Soenneker.Extensions.CancellationTokens
Combines two cancellation tokens while avoiding a linked CancellationTokenSource allocation when one is unnecessary.
Installation
dotnet add package Soenneker.Extensions.CancellationTokens
Usage
using Soenneker.Extensions.CancellationTokens;
CancellationToken combined = requestAborted.Link(
timeoutSource.Token,
out CancellationTokenSource? linkedSource);
using (linkedSource)
{
await PerformWork(combined);
}
The out source is owned by the caller. Keep it alive for the entire operation and dispose it afterward to unregister callbacks from the input tokens. It is null whenever no linked source was needed; disposing a nullable source with using is safe.
Allocation behavior
first.Link(second, out linkedSource) follows these paths:
| Inputs | Returned token | linkedSource |
|---|---|---|
| Tokens are identical | That token | null |
| Either token is already canceled | An already-canceled input token | null |
| Only one token can be canceled | The cancelable token | null |
| Neither token can be canceled | The default/non-cancelable token | null |
| Both distinct tokens can be canceled | A token linked to both inputs | Newly allocated source |
When a linked source is created, canceling either parent cancels the returned token. Canceling the linked source cancels only the combined token, not either parent. Disposal removes the link; it does not dispose or cancel the input sources.
This helper composes cancellation signals only. Work must still observe the returned token, and cancellation does not imply rollback or immediate interruption.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Soenneker.Extensions.CancellationTokens:
| Package | Downloads |
|---|---|
|
Soenneker.Blazor.Utils.ModuleImport
A Blazor utility library assisting with asynchronous module loading |
|
|
Soenneker.Utils.RateLimiting.Executor
A thread-safe utility designed to manage the rate at which tasks are executed, ensuring they are not run more frequently than a specified interval. |
|
|
Soenneker.Maui.Blazor.BrowserLogger
Adds the ability to browser console log in Blazor MAUI apps |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.25 | 54 | 9/12/2026 |
| 4.0.24 | 33,466 | 8/30/2026 |
| 4.0.23 | 208 | 8/29/2026 |
| 4.0.22 | 1,750 | 8/29/2026 |
| 4.0.21 | 36,731 | 7/28/2026 |
| 4.0.20 | 18,992 | 7/16/2026 |
| 4.0.19 | 28,223 | 6/18/2026 |
| 4.0.18 | 24,286 | 6/5/2026 |
| 4.0.17 | 34,836 | 4/22/2026 |
| 4.0.16 | 36,108 | 3/12/2026 |
| 4.0.15 | 190 | 3/12/2026 |
| 4.0.14 | 211 | 3/12/2026 |
| 4.0.13 | 367 | 3/12/2026 |
| 4.0.12 | 9,076 | 3/10/2026 |
| 4.0.11 | 4,686 | 3/9/2026 |
| 4.0.10 | 182 | 3/9/2026 |
| 4.0.9 | 1,390 | 3/9/2026 |
| 4.0.8 | 8,197 | 3/4/2026 |
| 4.0.7 | 41,076 | 1/2/2026 |
| 4.0.6 | 11,820 | 11/21/2025 |
Use NuGet trusted publishing in publishing workflows