Faster.EventBus 0.0.1

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

Faster.EventBus – High-Performance In-Process Command & Event Dispatcher

A faster, lower-allocation alternative to MediatR for .NET real-time workloads.

Faster.EventBus is an ultra-fast mediator/event bus for .NET.
It dispatches commands with Result<T> responses and publishes events using compiled pipeline delegates, avoiding runtime reflection and minimizing allocations.

It is ideal for high-frequency request handling, simulations, UI frameworks, real-time systems, plugin architectures, and performance-critical backends.


✨ Key Features

  • ✔ Near-zero overhead runtime
  • ✔ No reflection after startup
  • ✔ No boxing / extremely low memory allocation
  • ValueTask<T> pipelines
  • ✔ Middleware-style pipeline behaviors
  • ✔ Command/query request-response pattern
  • ✔ Publish/subscribe events
  • ✔ Fully DI-integrated via IServiceProvider
  • ✔ Benchmark-proven micro-latency advantage over MediatR

📦 Installation

services.AddEventBus(options =>
{
    options.AutoRegister = true; // automatically scans assemblies for handlers
});

📌 Define a Command

public record GetUserNameCommand(int UserId) : ICommand<Result<string>>;

🛠 Create a Command Handler

public class GetUserNameCommandHandler :
    ICommandHandler<GetUserNameCommand, Result<string>>
{
    public ValueTask<Result<string>> Handle(GetUserNameCommand command, CancellationToken ct)
    {
        return ValueTask.FromResult(Result<string>.Success($"User-{command.UserId}"));
    }
}

🧩 Register Services

var services = new ServiceCollection();

services.AddEventBus(options => options.AutoRegister = true);
services.AddTransient<ICommandHandler<GetUserNameCommand, Result<string>>, GetUserNameCommandHandler>();

var provider = services.BuildServiceProvider();
var bus = provider.GetRequiredService<EventDispatcher>();

🚀 Send a Command

var result = await bus.Send(new GetUserNameCommand(42));

if (result.IsSuccess)
    Console.WriteLine(result.Value); // Output: User-42

🔧 Pipeline Behavior Example

public class LoggingBehavior : ICommandPipelineBehavior<GetUserNameCommand, Result<string>>
{
    public async ValueTask<Result<string>> Handle(
        GetUserNameCommand cmd, CancellationToken ct, CommandHandlerDelegate<Result<string>> next)
    {
        Console.WriteLine("Before");
        var result = await next();
        Console.WriteLine("After");
        return result;
    }
}

Register Behavior

services.AddSingleton<ICommandPipelineBehavior<GetUserNameCommand, Result<string>>, LoggingBehavior>();

📣 Publish / Subscribe Events

public record UserCreatedEvent(int UserId) : IEvent;

public class UserCreatedEventHandler : IEventHandler<UserCreatedEvent>
{
    public ValueTask Handle(UserCreatedEvent evt, CancellationToken ct)
    {
        Console.WriteLine($"User created: {evt.UserId}");
        return ValueTask.CompletedTask;
    }
}

Use in application

bus.SubscribeEvent<UserCreatedEvent>();
await bus.PublishEvent(new UserCreatedEvent(10));

🥇 Benchmark Results vs MediatR

BenchmarkDotNet v0.15.6 • .NET 10 • 12-Core i5-12500H • Windows 11

Method Length Mean Ratio Alloc Alloc Ratio
Faster_EventBus_Result 1 98.57 ns 1.00x 168 B 1.00x
MediatR_Result 1 123.12 ns 1.25x 504 B 3.00x
Faster_EventBus_Result 100 8,672 ns 1.00x 16 KB 1.00x
MediatR_Result 100 11,688 ns 1.35x 50 KB 3.00x
Faster_EventBus_Result 1000 87,482 ns 1.00x 168 KB 1.00x
MediatR_Result 1000 118,251 ns 1.35x 504 KB 3.00x

🔥 Key takeaway

Faster.EventBus is 1.25–1.35x faster and uses 3x less memory.


❤️ Why Use It?

Need Solution
High-volume real-time commands
Minimal GC pressure
No reflection overhead
Mid-pipeline customization
Faster alternative to MediatR

🙌 Final Notes

Fast, simple, reliable.
Perfect when performance matters.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.1.3 227 11/23/2025
0.1.2 200 11/22/2025
0.1.1 219 11/22/2025
0.1.0 225 11/22/2025
0.0.4 354 11/21/2025
0.0.3 415 11/19/2025
0.0.2 422 11/18/2025
0.0.1 414 11/18/2025