![]() |
VOOZH | about |
dotnet add package Soenneker.Utils.BackgroundQueue --version 4.0.2402
NuGet\Install-Package Soenneker.Utils.BackgroundQueue -Version 4.0.2402
<PackageReference Include="Soenneker.Utils.BackgroundQueue" Version="4.0.2402" />
<PackageVersion Include="Soenneker.Utils.BackgroundQueue" Version="4.0.2402" />Directory.Packages.props
<PackageReference Include="Soenneker.Utils.BackgroundQueue" />Project file
paket add Soenneker.Utils.BackgroundQueue --version 4.0.2402
#r "nuget: Soenneker.Utils.BackgroundQueue, 4.0.2402"
#:package Soenneker.Utils.BackgroundQueue@4.0.2402
#addin nuget:?package=Soenneker.Utils.BackgroundQueue&version=4.0.2402Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.BackgroundQueue&version=4.0.2402Install as a Cake Tool
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
BackgroundQueue provides a fast, controlled way to execute background work in .NET applications.
It prevents overload by queueing and processing work asynchronously with configurable limits and built-in tracking.
Task and ValueTaskdotnet add package Soenneker.Utils.BackgroundQueue
Register the queue:
void ConfigureServices(IServiceCollection services)
{
services.AddBackgroundQueueAsSingleton();
}
await serviceProvider.WarmupAndStartBackgroundQueue(cancellationToken);
Synchronous start:
serviceProvider.WarmupAndStartBackgroundQueueSync(cancellationToken);
await serviceProvider.StopBackgroundQueue(cancellationToken);
Synchronous stop:
serviceProvider.StopBackgroundQueueSync(cancellationToken);
{
"Background": {
"QueueLength": 5000,
"LockCounts": false,
"Log": false
}
}
QueueLength � Maximum number of queued itemsLockCounts � Enables thread-safe tracking of running workLog � Enables debug loggingInject IBackgroundQueue:
IBackgroundQueue _queue;
void MyClass(IBackgroundQueue queue)
{
_queue = queue;
}
ValueTaskawait _queue.QueueValueTask(_ => someValueTask(), cancellationToken);
Taskawait _queue.QueueTask(_ => someTask(), cancellationToken);
Avoid capturing variables in lambdas when queueing work. Captured lambdas allocate and can impact performance under load.
await _queue.QueueTask(ct => DoWorkAsync(id, ct));
If id is a local variable, this creates a closure.
Use the stateful overloads with static lambdas.
await _queue.QueueValueTask(
myService,
static (svc, ct) => svc.ProcessAsync(ct),
ct);
await _queue.QueueTask(
(logger, id),
static (s, ct) => s.logger.RunAsync(s.id, ct),
ct);
Why this is better:
The non-stateful overloads remain available for convenience, but stateful queueing is recommended for hot paths.
await queue.WaitUntilEmpty(cancellationToken);
Check if work is still processing:
bool isProcessing = await queueInformationUtil.IsProcessing(cancellationToken);
Get current counts:
var (taskCount, valueTaskCount) =
await queueInformationUtil.GetCountsOfProcessing(cancellationToken);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on Soenneker.Utils.BackgroundQueue:
| Package | Downloads |
|---|---|
|
Soenneker.Redis.Util
The general purpose utility library leveraging Redis for all of your caching needs |
|
|
Soenneker.Tests.FixturedUnit
A fundamental xUnit test that stores UnitFixture and provides synthetic inversion of control |
|
|
Soenneker.Cosmos.Repository
A data persistence abstraction layer for Cosmos DB |
|
|
Soenneker.ServiceBus.Transmitter
A utility library for sending Service Bus messages |
|
|
Soenneker.Tests.HostedUnit
A fundamental test that stores the TestHost and provides synthetic inversion of control |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.2402 | 0 | 6/18/2026 |
| 4.0.2401 | 3,919 | 6/16/2026 |
| 4.0.2400 | 7,096 | 6/16/2026 |
| 4.0.2399 | 18,680 | 6/10/2026 |
| 4.0.2398 | 266 | 6/10/2026 |
| 4.0.2397 | 698 | 6/10/2026 |
| 4.0.2395 | 7,542 | 6/9/2026 |
| 4.0.2394 | 6,910 | 6/9/2026 |
| 4.0.2393 | 14,721 | 6/6/2026 |
| 4.0.2392 | 4,964 | 6/6/2026 |
| 4.0.2391 | 831 | 6/6/2026 |
| 4.0.2389 | 4,594 | 6/6/2026 |
| 4.0.2388 | 95 | 6/6/2026 |
| 4.0.2386 | 159 | 6/5/2026 |
| 4.0.2383 | 4,506 | 6/5/2026 |
| 4.0.2379 | 55,900 | 5/13/2026 |
| 4.0.2378 | 4,481 | 5/12/2026 |
| 4.0.2377 | 99 | 5/12/2026 |
| 4.0.2375 | 23,832 | 5/2/2026 |
| 4.0.2374 | 32,576 | 4/24/2026 |
Update actions/checkout action to v7 (#3036)