Пример #1
0
 private void ExecuteHandler <TEvent>(EventHandlerDelegate <TEvent> handler, TEvent @event, bool safe) where TEvent : IEvent
 {
     if (safe)
     {
         try
         {
             handler.Invoke(@event);
         }
         catch (Exception ex)
         {
             try
             {
                 Handle(new ExceptionEvent(ex));
             }
             catch
             {
                 // ignored - this is if an exception handler throws an exception.
             }
         }
     }
     else
     {
         handler.Invoke(@event);
     }
 }
Пример #2
0
 /// <summary>
 /// Execute event handler.
 /// </summary>
 /// <param name="eventHandler">Event handler delegate.</param>
 /// <param name="event">Event to publish.</param>
 /// <param name="cancellationToken">Cancellation token.</param>
 /// <returns>Asynchronous task.</returns>
 protected virtual Task ExecuteEventHandlerAsync(EventHandlerDelegate eventHandler, IEvent @event, CancellationToken cancellationToken)
 {
     return(eventHandler.Invoke(@event, cancellationToken));
 }