Skip to content

Handling Events

Petar Marinov edited this page Jun 25, 2018 · 5 revisions

When event is published EventBroker will resolve all available event handlers, create a delegate for each of them encapsulating filtering, execution and exception handling and then pass them to IEventHandlerRunner for execution.
IEventHandlerRunner will run these actions according to it's implementation.

Filtering

First the IEventHandler.ShouldHandle(TEvent @event); or the corresponding delegate passed in EventBroker.Subscribe method is called.
If the result is false then IEventHandler.Handle(TEvent @event); or the corresponding delegate will not be executed.
If filter is not provided the handler will be executed.

Execution

The IEventHandler.Handle(TEvent @event); or the corresponding delegate passed in EventBroker.Subscribe is executed.

Exception Handling

If there is an unhandled exception during evaluation of filter or execution IEventHandler.OnError(Exception exception, TEvent @event) or the corresponding delegate passed in EventBroker.Subscribe is called.
If OnError method or corresponding delegate throws exception, it will be swallowed.
If exception handling delegate is not provided exception will be swallowed.

Clone this wiki locally