Interface IEventBus
- Namespace
- ReflectionEventing
- Assembly
- ReflectionEventing.dll
Provides event publishing capabilities.
public interface IEventBus
- Extension Methods
Methods
PublishAsync<TEvent>(TEvent, CancellationToken)
Adds the specified event to the queue.Another scope will take over execution as configured.
Task PublishAsync<TEvent>(TEvent eventItem, CancellationToken cancellationToken = default) where TEvent : class
Parameters
eventItemTEventThe event to publish.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task
A task that represents the asynchronous operation.
Type Parameters
TEventThe type of the event to publish.
Remarks
The method only adds the event to the execution queue, it does not wait for its successful execution.
SendAsync<TEvent>(TEvent, CancellationToken)
Sends the specified event asynchronously within the current scope, waiting for its execution.
Task SendAsync<TEvent>(TEvent eventItem, CancellationToken cancellationToken = default) where TEvent : class
Parameters
eventItemTEventThe event to send.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task
A task that represents the asynchronous operation.
Type Parameters
TEventThe type of the event to send.
Remarks
This method gets the consumers for the specified event type from the consumer provider and then uses the service provider to get the required service for each consumer. Each consumer is then used to consume the event asynchronously.