CodeWF.Toolkit.EventBus
1.1.10
dotnet add package CodeWF.Toolkit.EventBus --version 1.1.10
NuGet\Install-Package CodeWF.Toolkit.EventBus -Version 1.1.10
<PackageReference Include="CodeWF.Toolkit.EventBus" Version="1.1.10" />
<PackageVersion Include="CodeWF.Toolkit.EventBus" Version="1.1.10" />
<PackageReference Include="CodeWF.Toolkit.EventBus" />
paket add CodeWF.Toolkit.EventBus --version 1.1.10
#r "nuget: CodeWF.Toolkit.EventBus, 1.1.10"
#:package CodeWF.Toolkit.EventBus@1.1.10
#addin nuget:?package=CodeWF.Toolkit.EventBus&version=1.1.10
#tool nuget:?package=CodeWF.Toolkit.EventBus&version=1.1.10
CodeWF.Toolkit.EventBus
轻量进程内事件总线:发布订阅、Command/Query 读写分离、[EventHandler] 特性注册与程序集扫描,适用于桌面与应用服务间模块解耦,零第三方依赖。Lightweight in-process event bus with pub/sub, CQRS-style commands and queries, zero third-party dependencies.
安装
dotnet add package CodeWF.Toolkit.EventBus
零第三方依赖(仅本仓 CodeWF.Toolkit.Lang 随包带入);目标框架 net10.0。容器/分布式形态见 Prism 集成、ASP.NET Core 集成、TCP 分布式总线。
快速使用
using CodeWF.Toolkit.EventBus;
var bus = new EventBus();
// lambda 订阅
bus.Subscribe<GreetCommand>(cmd => Console.WriteLine(cmd.Name));
bus.Publish(new GreetCommand("hi"));
await bus.PublishAsync(new GreetCommand("hi"));
// 查询:处理器设置 query.Result
bus.Subscribe(new TimeQueryHandler());
var query = new TimeQuery();
bus.Query(query);
public sealed class TimeQueryHandler
{
[EventHandler]
private void ReceiveTimeQueryAsync(TimeQuery query) => query.Result = DateTime.Now;
}
Command/Query<TResponse>基类区分写命令与读查询。[EventHandler(Order=n)]控制同命令多处理器顺序;Subscribe(Assembly[])扫描实例处理器,RegisterServiceHandlerAction提供构造依赖。- 通用 IOC 场景(无 MEDI/Prism):
EventBusRegistrationExtensions.AddEventBus(...)+UseEventBus(...)。
注意事项
- 处理器异常不会默默吞掉:发布端异步方法会抛出,注意 UI 侧捕获。
文档
| 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
- CodeWF.Toolkit.Lang (>= 1.1.10)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on CodeWF.Toolkit.EventBus:
| Package | Downloads |
|---|---|
|
CodeWF.Toolkit.NetWrapper
TCP/UDP 通信封装与命令分发:客户端/服务端、心跳、断线重连,内置远程文件系统与断点续传能力。TCP/UDP helpers and command dispatching with built-in remote file system and resumable file transfer. |
|
|
CodeWF.Toolkit.EventBus.AspNetCore
事件总线的 ASP.NET Core 集成:依赖注入注册、请求管线启动与处理器自动发现。ASP.NET Core integration for the event bus. |
|
|
CodeWF.Toolkit.EventBus.Prism
事件总线的 Prism/DryIoc 容器集成:在 Prism 应用中完成注册、处理器扫描与启动。Prism/DryIoc container integration for the event bus. |
|
|
CodeWF.Toolkit.EventBus.Socket
基于 TCP 的分布式事件总线:Pub/Sub、Query/Response、心跳保活、断线重连与离线消息补发,不依赖第三方消息队列。Distributed event bus over TCP with heartbeat, reconnect and offline replay, without third-party MQ. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.10 | 87 | 11/20/2026 |
| 1.1.9 | 127 | 11/16/2026 |
| 1.1.8 | 144 | 11/16/2026 |
| 1.1.7 | 182 | 11/16/2026 |
| 1.1.6 | 272 | 11/8/2026 |
| 1.1.5 | 118 | 11/8/2026 |
| 1.1.4 | 129 | 11/8/2026 |
| 1.1.3 | 118 | 11/8/2026 |
| 1.1.2 | 228 | 11/1/2026 |
| 1.1.1 | 212 | 10/26/2026 |
| 1.1.0 | 304 | 10/22/2026 |
| 1.1.0-alpha.1 | 102 | 10/21/2026 |
| 1.0.0.27 | 236 | 10/19/2026 |
| 1.0.0.26 | 200 | 10/16/2026 |
| 1.0.0.25 | 127 | 10/16/2026 |
| 1.0.0.24 | 146 | 10/15/2026 |
| 1.0.0.23 | 138 | 10/15/2026 |
| 1.0.0.22 | 134 | 10/15/2026 |
| 1.0.0.20 | 132 | 10/15/2026 |
| 1.0.0.19 | 384 | 10/15/2026 |