Soenneker.Utils.BackgroundQueue
4.0.2222
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.BackgroundQueue --version 4.0.2222
NuGet\Install-Package Soenneker.Utils.BackgroundQueue -Version 4.0.2222
<PackageReference Include="Soenneker.Utils.BackgroundQueue" Version="4.0.2222" />
<PackageVersion Include="Soenneker.Utils.BackgroundQueue" Version="4.0.2222" />
<PackageReference Include="Soenneker.Utils.BackgroundQueue" />
paket add Soenneker.Utils.BackgroundQueue --version 4.0.2222
#r "nuget: Soenneker.Utils.BackgroundQueue, 4.0.2222"
#:package Soenneker.Utils.BackgroundQueue@4.0.2222
#addin nuget:?package=Soenneker.Utils.BackgroundQueue&version=4.0.2222
#tool nuget:?package=Soenneker.Utils.BackgroundQueue&version=4.0.2222
Soenneker.Utils.BackgroundQueue
A high-performance background Task/ValueTask queue
Overview
BackgroundQueue provides an efficient way to manage background task execution in .NET applications. It helps prevent application overload by processing tasks in a controlled, asynchronous manner.
Features
- Supports both
ValueTaskandTasktypes. - Configurable queue size to limit resource usage.
- Built-in tracking of running and pending tasks.
- Extension methods for easy setup and management.
- Includes a hosted service for automatic background processing.
Installation
dotnet add package Soenneker.Utils.BackgroundQueue
Register the BackgroundQueue:
void ConfigureServices(IServiceCollection services)
{
services.AddBackgroundQueueAsSingleton();
}
Starting
await serviceProvider.WarmupAndStartBackgroundQueue(cancellationToken);
For synchronous start:
serviceProvider.WarmupAndStartBackgroundQueueSync(cancellationToken);
Stopping
To stop the service:
await serviceProvider.StopBackgroundQueue(cancellationToken);
For synchronous stop:
serviceProvider.StopBackgroundQueueSync(cancellationToken);
Configuration
Configure the queue length and task tracking settings in your application:
{
"Background": {
"QueueLength": 5000,
"LockCounts": false,
"Log": false
}
}
QueueLength: Defines the maximum number of tasks in the queue.LockCounts: Enables thread-safe counting of running tasks.Log: Outputs task tracking information toILogger
Initializing the Queue
To use BackgroundQueue, you probably want to inject it via your constructor:
IBackgroundQueue _queue;
void MyClass(IBackgroundQueue queue)
{
_queue = queue;
}
Queueing Tasks
Queuing a ValueTask
Rather than wrapping the task, you can elide it directly to avoid an extra state machine:
await _queue.QueueValueTask(_ => someValueTask(), cancellationToken);
Queuing a Task
Similarly, for Task:
await _queue.QueueTask(_ => someTask(), cancellationToken);
Waiting for Queue to Empty
To ensure all queued tasks finish before proceeding:
await queue.WaitUntilEmpty(cancellationToken);
Task Tracking
The queue tracks:
- The number of active
ValueTaskandTaskinstances. - Whether any tasks are still processing.
To check if tasks are running:
bool isProcessing = await queueInformationUtil.IsProcessing(cancellationToken);
To get current task counts:
var (taskCount, valueTaskCount) = await queueInformationUtil.GetCountsOfProcessing(cancellationToken);
| 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
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.1)
- Nito.AsyncEx (>= 5.1.2)
- Soenneker.Extensions.Configuration (>= 4.0.745)
- Soenneker.Extensions.Double (>= 4.0.447)
- Soenneker.Extensions.MethodInfo (>= 4.0.350)
- Soenneker.Extensions.Task (>= 4.0.107)
- Soenneker.Extensions.ValueTask (>= 4.0.97)
- Soenneker.Utils.Delay (>= 4.0.42)
NuGet packages (6)
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.Integration
An abstract xUnit test class for end-to-end integration (involving WebApplicationFactory) tests |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.2275 | 2,919 | 2/12/2026 |
| 4.0.2274 | 1,477 | 2/11/2026 |
| 4.0.2273 | 5,845 | 2/10/2026 |
| 4.0.2272 | 32 | 2/10/2026 |
| 4.0.2269 | 10,952 | 2/4/2026 |
| 4.0.2268 | 1,674 | 2/4/2026 |
| 4.0.2267 | 5,654 | 1/28/2026 |
| 4.0.2266 | 6,516 | 1/22/2026 |
| 4.0.2265 | 671 | 1/22/2026 |
| 4.0.2263 | 8,746 | 1/19/2026 |
| 4.0.2262 | 1,749 | 1/18/2026 |
| 4.0.2261 | 9,754 | 1/14/2026 |
| 4.0.2260 | 2,559 | 1/13/2026 |
| 4.0.2259 | 365 | 1/13/2026 |
| 4.0.2258 | 2,490 | 1/13/2026 |
| 4.0.2257 | 4,892 | 1/13/2026 |
| 4.0.2256 | 4,455 | 1/12/2026 |
| 4.0.2255 | 100 | 1/12/2026 |
| 4.0.2254 | 8,202 | 1/9/2026 |
| 4.0.2222 | 7,533 | 12/17/2025 |