Sparkdo.MassHub.Threading 1.0.3

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Sparkdo.MassHub.Threading --version 1.0.3
                    
NuGet\Install-Package Sparkdo.MassHub.Threading -Version 1.0.3
                    
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="Sparkdo.MassHub.Threading" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sparkdo.MassHub.Threading" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Sparkdo.MassHub.Threading" />
                    
Project file
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 Sparkdo.MassHub.Threading --version 1.0.3
                    
#r "nuget: Sparkdo.MassHub.Threading, 1.0.3"
                    
#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 Sparkdo.MassHub.Threading@1.0.3
                    
#: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=Sparkdo.MassHub.Threading&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Sparkdo.MassHub.Threading&version=1.0.3
                    
Install as a Cake Tool

Sparkdo.MassHub.Threading

提供消息总线基础设施所需的异步同步原语和并发处理工具集,包括异步事件信号、通道处理器、连续后台任务和指数退避策略。

功能特性

  • AsyncAutoResetEvent:异步自动重置事件,支持单次/批量释放等待者,基于 Stephen Toub 的实现
  • ChannelProcessor<T>:多消费者并发通道处理器,从 IAsyncEnumerable 数据源并行消费并分发给指定的处理委托
  • ContinuousTask:持续后台任务,失败时自动重启并配合指数退避,支持优雅关闭
  • ExponentialBackoff:带随机抖动的指数退避策略,防止惊群效应,延迟上限可配置

安装

dotnet add package Sparkdo.MassHub.Threading

使用示例

// 异步自动重置事件
var evt = new AsyncAutoResetEvent();
await evt.WaitAsync(cancellationToken); // 等待信号
evt.Set();                               // 释放一个等待者

// 多消费者通道处理
var processor = new ChannelProcessor<Message>(
    source: ct => channel.Reader.ReadAllAsync(ct),
    handler: (msg, ct) => ProcessMessageAsync(msg),
    concurrency: 4);

// 连续后台任务(含退避)
var worker = new ContinuousTask(async ct =>
{
    await DoWorkAsync(ct);
});
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Sparkdo.MassHub.Threading:

Package Downloads
Sparkdo.MassHub

Sparkdo 消息总线核心库,提供消息分发、中间件管道、路由、序列化等核心功能

Sparkdo.MassHub.Outbox

Sparkdo 消息总线发送端 Outbox 中间件,事务性发送消息

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4-preview.3 112 6/8/2026
1.0.4-preview.2 107 6/7/2026
1.0.4-preview.1 109 6/7/2026
1.0.3 228 6/6/2026