ZeidLab.ToolBox.EventBuss 1.0.2506.2717

dotnet add package ZeidLab.ToolBox.EventBuss --version 1.0.2506.2717
                    
NuGet\Install-Package ZeidLab.ToolBox.EventBuss -Version 1.0.2506.2717
                    
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="ZeidLab.ToolBox.EventBuss" Version="1.0.2506.2717" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeidLab.ToolBox.EventBuss" Version="1.0.2506.2717" />
                    
Directory.Packages.props
<PackageReference Include="ZeidLab.ToolBox.EventBuss" />
                    
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 ZeidLab.ToolBox.EventBuss --version 1.0.2506.2717
                    
#r "nuget: ZeidLab.ToolBox.EventBuss, 1.0.2506.2717"
                    
#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.
#addin nuget:?package=ZeidLab.ToolBox.EventBuss&version=1.0.2506.2717
                    
Install as a Cake Addin
#tool nuget:?package=ZeidLab.ToolBox.EventBuss&version=1.0.2506.2717
                    
Install as a Cake Tool

ZeidLab.ToolBox.EventBuss

🤔 What is ZeidLab.ToolBox.EventBuss Library?

ZeidLab.ToolBox.EventBuss is a lightweight, high-performance in-process event handling and messaging library for .NET applications. It provides a clean and efficient way to implement event-driven architectures, enabling loose coupling between components through a publisher-subscriber model. The library supports both event publishing (fire-and-forget) and request-response patterns, making it versatile for various communication needs within your application.

🎁 Features

  • Event Publishing: Fire-and-forget event publishing with automatic handler discovery and invocation
  • Request Handling: Send requests and optionally receive responses using a clean, typed interface
  • Automatic Registration: Scan assemblies to automatically discover and register event and request handlers
  • High-Performance: Optimized for minimal overhead and maximum throughput in critical paths
  • Background Processing: Events are processed asynchronously in a background service
  • Parallel Execution: Configurable parallel processing of events for improved throughput
  • Dependency Injection: Seamless integration with Microsoft's dependency injection system

^ Back To Top

📦 Installation

To use ZeidLab.ToolBox.EventBuss in your project, you can install it via NuGet:

dotnet add package ZeidLab.ToolBox.EventBuss

For more information, please visit EventBuss Package on NuGet.

^ Back To Top

📝 ChangeLogs

With each release, we add new features and fix bugs. You can find the full changelog at EventBuss Releases.

^ Back To Top

📖 Usage and Configuration

EventBuss provides a straightforward API for event publishing and request handling in your .NET applications.

Basic Configuration

Register EventBuss in your application's service collection during startup:

// Add with default configuration
builder.Services.AddEventBuss();

// Or with custom configuration
builder.Services.AddEventBuss(options =>
{
    // Register handlers from specific assemblies
    options.RegisterFromAssembly(typeof(Program).Assembly);
    
    // Discover handlers from referenced assemblies
    options.FromDependencies = true;
    
    // Configure parallel processing (optional)
    // The default value is the number of available processors cores
    // One thread per core is recommended for optimal performance
    options.MaxDegreeOfParallelism = 4;
});

Publishing Events

Create event object by implementing the IAppEvent interface. It can be a simple record or class, however we recommend you to use a readonly type for optimized performance. In this example it is a readonly record struct . Then, use the IEventBussService to publish events:

// Define an event
public readonly record struct UserCreatedEvent(string UserId, string Username) : IAppEvent;

// Publish an event
_eventBussService.Publish(new UserCreatedEvent("user123", "johndoe"));

Creating Event Handlers

Implement the IAppEventHandler<T> interface to handle specific events:

public class UserCreatedEventHandler : IAppEventHandler<UserCreatedEvent>
{
    private readonly ILogger<UserCreatedEventHandler> _logger;
    
    public UserCreatedEventHandler(ILogger<UserCreatedEventHandler> logger)
    {
        _logger = logger;
    }
    
    public async Task HandleAsync(UserCreatedEvent @event, CancellationToken cancellationToken)
    {
        _logger.LogInformation("User created: {UserId}, {Username}", @event.UserId, @event.Username);
        await Task.CompletedTask;
    }
}

Sending Requests

Send requests and receive responses using the request-response pattern. The request can be a simple record or class, however we recommend you to use a readonly type for optimized performance. In this example it is a readonly record struct :

// Define a request and handler
public readonly record struct GetUserRequest(string UserId) : IRequest<UserDetails>;

public class GetUserRequestHandler : IRequestHandler<GetUserRequest, UserDetails>
{
    private readonly IUserRepository _repository;
    
    public GetUserRequestHandler(IUserRepository repository)
    {
        _repository = repository;
    }
    
    public async Task<UserDetails> HandleAsync(GetUserRequest request, CancellationToken cancellationToken)
    {
        return await _repository.GetUserByIdAsync(request.UserId, cancellationToken);
    }
}

// Send the request and get a response
var userDetails = await _eventBussService.SendAsync<GetUserRequest, UserDetails>(
    new GetUserRequest("user123"), 
    cancellationToken
);

Core Components

Component Description
IEventBussService Core service for publishing events and sending requests
IAppEvent Marker interface for event objects
IAppEventHandler<T> Interface for event handlers
IRequest<TResponse> Interface for request objects that expect a response
IRequest Interface for request objects that don't expect a response
IRequestHandler<TRequest,TResponse> Interface for request handlers that return a response
IRequestHandler<TRequest> Interface for request handlers that do not return a response
EventBussOptions Configuration options for EventBuss

^ Back To Top

⭐️ Star and Follow

Star this repository and follow me on GitHub to stay informed about new releases and updates. Your support fuels this project's growth!

^ Back To Top

💡 Love My Work? Support the Journey!

If my content adds value to your projects, consider supporting me via crypto.

  • Bitcoin: bc1qlfljm9mysdtu064z5cf4yq4ddxgdfztgvghw3w
  • USDT(TRC20): TJFME9tAnwdnhmqGHDDG5yCs617kyQDV39

Thank you for being part of this community—let’s build smarter, together

^ Back To Top

🤝 Contributions

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

  1. Fork the repository
  2. Create a new branch for your feature or bugfix
  3. Commit your changes following the project guidelines
  4. Push your branch and submit a pull request

^ Back To Top

License

This project is licensed under the MIT License. See the LICENSE file for details.

^ Back To Top

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
1.0.2506.2717 54 6/27/2025