Class Event<TEvent>
event notification bus which uses an in-process pub/sub messaging system
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public sealed class Event<TEvent> : EventBase
Type Parameters
| Name | Description |
|---|---|
| TEvent | the type of notification event dto |
Constructors
Event(IEnumerable<IEventHandler<TEvent>>)
instantiates an event bus for the given event dto type.
Declaration
public Event(IEnumerable<IEventHandler<TEvent>> eventHandlers = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<IEventHandler<TEvent>> | eventHandlers | a collection of concrete event handler implementations that should receive notifications from this event bus |
Methods
PublishAsync(TEvent, Mode, CancellationToken)
publish the given model/dto to all the subscribers of the event notification
Declaration
public Task PublishAsync(TEvent eventModel, Mode waitMode = Mode.WaitForAll, CancellationToken cancellation = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| TEvent | eventModel | the notification event model/dto to publish |
| Mode | waitMode | specify whether to wait for none, any or all of the subscribers to complete their work |
| System.Threading.CancellationToken | cancellation | an optional cancellation token |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | a Task that matches the wait mode specified. WaitForNone returns an already completed Task (fire and forget). WaitForAny returns a Task that will complete when any of the subscribers complete their work. WaitForAll return a Task that will complete only when all of the subscribers complete their work. |