Lite.EventIpc 1.2.0

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

Lite Event Aggregator and IPC Transporter

Lite.EventIPC is a cross-platform local Event Aggregator and remote IPC (inter-process communication) service library for C#. The pattern is used for decoupling publishers and subscribers in a single or multiple applications. The library can be easily extended for custom IPC transports using the IEventTransport interface to suit your needs (need I say, DBus?)

The Event Aggregator service in C# pattern is useful for decoupling publishers and subscribers in an application.

Features

This implementation is features:

  • Simple, thread-safe, and async friendly
  • Local subscribe/publish event aggregator
    • Subscribe and Publish - for one-way events
    • SubscribeRequest and RequestAsync - for publishing with an awaited response (including timeouts)
  • Uses weak references to avoid memory leaks
  • Cleans up dead references during Publish.
  • Prevents memory leaks when subscribers are no longer needed.
  • DI-friendly with extensions and hosted service
  • Built-in IPC transport mechanisms (inter-process communication) with JSON serialization:
    • Named Pipe Transport
    • Memory-Mapped File Transport (Windows OS only)
    • TCP/IP Transport
  • 2 types of IPC communication:
    • One-way publish/subscribe (IEventTransport)
    • (COMING SOON) Bidirectional request/response with timeouts (IEventEnvelopeTransport)

Usage

Basic Subscribe/Publish

using Lite.EventIpc;

public class UserCreatedEvent
{
  public string UserName { get; set; }
}

static void Main()
{
  var eventAggregator = new EventAggregator();

  // Subscribe
  eventAggregator.Subscribe<UserCreatedEvent>(e =>
    Console.WriteLine($"User created: {e.Username}"));

  // Publish
  eventAggregator.Publish(new UserCreatedEvent { Username = "Damian" })
}

Publish Requests with Awaited Responses

Subscribing to a request event allows users to respond with a different object. This is useful for RPC-like communication.

using Lite.EventIpc;

public async Task SubscribeWithResponse()
{
  // Subscribe to Ping events that respond with Pong
  _eventAggregator.SubscribeRequest<Ping, Pong>(EventSubscribe_PingAsync);

  // Send a Ping request event and await the Pong response
  Ping ping = new Ping("HELLO!");
  Pong? response = await _eventAggregator.RequestAsync<Ping, Pong>(ping);

  if (response is not null)
  {
    // Received PONG!
  }
}

private async Task<Pong> EventSubscribe_PingAsync(Ping ping)
{
  var response = "Received PING loud and clear";
  return new Pong(response);
}

Handling Request Event Timeouts

Borrowing from the previous example, you can specify a timeout when sending a request event. If no subscriber responds within the timeout period, null is returned.

public async Task SubscribeWithResponse()
{
  // ...

  // Send a Ping request event and await the Pong response
  Ping ping = new Ping("HELLO!");
  var timeout = TimeSpan.FromMilliseconds(3000);

  Pong? response = null;
  try
  {
    response = await _eventAggregator.RequestAsync<Ping, Pong>(ping, timeout);
  }
  catch (TimeoutException)
  {
    // Handle timeout (no response received in time)
  }

  // ...
}

Architecture

Why Weak References

If you store strong references to handlers, subscribers will never be collected. Using WeakReference ensures that if the subscriber is no longer needed, it can be GC'd.

History

v1.1.0

  • Option to include Microsoft.Extensions.Logger for deep-logging

Future Considerations

  • Send IPC only for specified event types.
  • Possibly, filtering or priority-based dispatching.
  • Refactor IEventTransport toIIpcEvent for clarity.
  • Refactor Transporter namespace to Ipc or IpcTransport for clarity.
  • Refactor IEventEnvelopeTransport under IpcReceipted namespace for clarity.
  • Security: Named Pipes, MMF, and TCP should use proper ACLs / TLS / auth in production
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

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.2.0 30 1/24/2026
1.2.0-alpha1 31 1/24/2026
1.0.0 120 11/28/2025