Soenneker.Extensions.ValueTask
4.0.120
Prefix Reserved
dotnet add package Soenneker.Extensions.ValueTask --version 4.0.120
NuGet\Install-Package Soenneker.Extensions.ValueTask -Version 4.0.120
<PackageReference Include="Soenneker.Extensions.ValueTask" Version="4.0.120" />
<PackageVersion Include="Soenneker.Extensions.ValueTask" Version="4.0.120" />
<PackageReference Include="Soenneker.Extensions.ValueTask" />
paket add Soenneker.Extensions.ValueTask --version 4.0.120
#r "nuget: Soenneker.Extensions.ValueTask, 4.0.120"
#:package Soenneker.Extensions.ValueTask@4.0.120
#addin nuget:?package=Soenneker.Extensions.ValueTask&version=4.0.120
#tool nuget:?package=Soenneker.Extensions.ValueTask&version=4.0.120
Soenneker.Extensions.ValueTask
Helpers for context-free awaits, synchronous bridges, and observed fire-and-forget ValueTask operations.
Installation
dotnet add package Soenneker.Extensions.ValueTask
Avoid context capture
using Soenneker.Extensions.ValueTask;
Result result = await GetResultAsync().NoSync();
NoSync() is shorthand for ConfigureAwait(false) for both ValueTask and ValueTask<T>. It prevents the await from requesting the current synchronization context; it does not guarantee a different continuation thread.
Synchronous bridges
Result result = GetResultAsync().AwaitSync();
AwaitSync() blocks the current thread and unwraps the original exception. AwaitSyncSafe() registers a context-free continuation before blocking, which avoids the common deadlock caused solely by resuming that await on the blocked context. It still blocks a thread and cannot make an underlying operation safe if that operation itself requires the blocked context. Prefer normal await.
The cancellation token passed to AwaitSyncSafe() cancels only the synchronous wait. It does not cancel the underlying ValueTask; that operation can continue after the caller receives OperationCanceledException. Pass cancellation into the operation itself when it must stop.
Observe detached work
PublishMetricAsync().FireAndForgetSafe(exception =>
logger.LogError(exception, "Metric publishing failed"));
FireAndForgetSafe() consumes the result or exception once and optionally invokes a synchronous callback for faults and cancellation. Callback failures are swallowed so a detached diagnostic cannot become an unhandled continuation failure.
Fire-and-forget work is not durable: it does not keep the process alive, retry, or guarantee delivery. Use a background queue for important operations.
ValueTask rules still apply
These helpers consume the supplied ValueTask. Unless its source explicitly permits otherwise, do not await it again, call AsTask() afterward, or invoke more than one of these helpers on the same instance. Store a Task instead when an operation must support multiple consumers.
| 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 (36)
Showing the top 5 NuGet packages that depend on Soenneker.Extensions.ValueTask:
| Package | Downloads |
|---|---|
|
Soenneker.Utils.AsyncSingleton
An externally initializing singleton that uses double-check asynchronous locking, with optional async and sync disposal |
|
|
Soenneker.Extensions.Stream
A collection of helpful Stream extension methods |
|
|
Soenneker.Extensions.Enumerable
A collection of helpful enumerable extension methods |
|
|
Soenneker.Utils.BackgroundQueue
A high-performance background Task/ValueTask queue |
|
|
Serilog.Sinks.XUnit.Injectable
The injectable, xUnit test output sink for Serilog |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.120 | 62,703 | 8/30/2026 |
| 4.0.119 | 31,607 | 8/29/2026 |
| 4.0.118 | 426,781 | 7/28/2026 |
| 4.0.117 | 227,457 | 7/16/2026 |
| 4.0.116 | 254,869 | 6/18/2026 |
| 4.0.115 | 240,063 | 6/5/2026 |
| 4.0.113 | 586,457 | 3/12/2026 |
| 4.0.112 | 3,762 | 3/12/2026 |
| 4.0.111 | 1,363 | 3/12/2026 |
| 4.0.110 | 12,429 | 3/12/2026 |
| 4.0.109 | 95,485 | 3/10/2026 |
| 4.0.108 | 59,636 | 3/9/2026 |
| 4.0.107 | 5,988 | 3/9/2026 |
| 4.0.106 | 3,321 | 3/9/2026 |
| 4.0.105 | 116,546 | 3/4/2026 |
| 4.0.104 | 332,885 | 1/12/2026 |
| 4.0.103 | 95,901 | 1/6/2026 |
| 4.0.102 | 51,476 | 1/2/2026 |
| 4.0.101 | 45,703 | 12/31/2025 |
| 4.0.100 | 176 | 12/31/2025 |
Fix ValueTask continuation and cancellation safety