Linger.Background
1.3.2-preview
This is a prerelease version of Linger.Background.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Linger.Background --version 1.3.2-preview
NuGet\Install-Package Linger.Background -Version 1.3.2-preview
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="Linger.Background" Version="1.3.2-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Linger.Background" Version="1.3.2-preview" />
<PackageReference Include="Linger.Background" />
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 Linger.Background --version 1.3.2-preview
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Linger.Background, 1.3.2-preview"
#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 Linger.Background@1.3.2-preview
#: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=Linger.Background&version=1.3.2-preview&prerelease
#tool nuget:?package=Linger.Background&version=1.3.2-preview&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Linger.Background
一个轻量级的.NET后台任务处理库。
介绍
Linger.Background为.NET开发者提供了简单的工具和扩展,用于在.NET应用程序中管理和执行基本的后台任务。
功能
- 基础后台任务队列
- 简单的工作者处理机制
- 任务取消支持
- 与.NET依赖注入集成
使用示例
// 注册服务
public void ConfigureServices(IServiceCollection services)
{
// 根据实际项目中的扩展方法来注册Background服务
services.AddHostedService<QueuedHostedService>();
services.AddSingleton<IBackgroundTaskQueue>(ctx =>
{
//if (!int.TryParse(hostContext.Configuration["QueueCapacity"], out var queueCapacity))
var queueCapacity = 100;
return new BackgroundTaskQueue(queueCapacity);
});
}
// 使用后台任务队列
public class SampleService
{
private readonly IBackgroundTaskQueue _taskQueue;
public SampleService(IBackgroundTaskQueue taskQueue)
{
_taskQueue = taskQueue;
}
public async Task EnqueueWorkItem()
{
// 注意: Lambda 接收两个参数 (IServiceProvider, CancellationToken)
await _taskQueue.QueueBackgroundWorkItemAsync(async (serviceProvider, token) =>
{
// 可以从 serviceProvider 获取服务
var logger = serviceProvider.GetRequiredService<ILogger<SampleService>>();
// 执行后台工作,支持取消
await Task.Delay(1000, token);
logger.LogInformation("后台任务执行完成");
});
}
// 支持外部取消令牌
public async Task EnqueueWorkItemWithCancellation(CancellationToken cancellationToken)
{
await _taskQueue.QueueBackgroundWorkItemAsync(
async (serviceProvider, token) =>
{
// 执行后台工作
await Task.Delay(1000, token);
},
cancellationToken); // 可选的取消令牌参数
}
}
安装
Package Manager命令行
PM> Install-Package Linger.Background
.NET CLI命令行
> dotnet add package Linger.Background
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.7)
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.7)
-
net9.0
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.7)
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 |
|---|---|---|
| 1.6.4 | 38 | 8/16/2026 |
| 1.6.3 | 93 | 8/5/2026 |
| 1.6.2 | 113 | 8/2/2026 |
| 1.6.0 | 97 | 7/25/2026 |
| 1.5.5 | 101 | 7/23/2026 |
| 1.5.4-preview | 89 | 7/21/2026 |
| 1.5.3-preview | 89 | 7/20/2026 |
| 1.5.2-preview | 92 | 7/19/2026 |
| 1.5.1-preview | 101 | 7/15/2026 |
| 1.5.0-preview | 86 | 7/14/2026 |
| 1.4.4-preview | 105 | 6/16/2026 |
| 1.4.3-preview | 99 | 6/15/2026 |
| 1.4.2 | 109 | 5/20/2026 |
| 1.4.1-preview | 102 | 5/12/2026 |
| 1.4.0 | 101 | 5/6/2026 |
| 1.3.3-preview | 96 | 5/5/2026 |
| 1.3.2-preview | 97 | 4/29/2026 |
| 1.3.1-preview | 100 | 4/28/2026 |
| 1.3.0-preview | 96 | 4/27/2026 |
| 1.2.0-preview | 107 | 3/29/2026 |
Loading failed