private void PublishInternal <T>(T @event, bool doAsync) { var subscribers = _subscriptionService.GetSubscriptions <T>(); foreach (var subscriber in subscribers) { if (doAsync && subscriber.IsAsynchronous) { var eventSubscriber = subscriber; var t = new Thread(() => { try { eventSubscriber.Notify(@event); } catch (Exception ex) { string message = $@"Error occurred when the following subcriber '{eventSubscriber.GetType().FullName}' was notified about event '{@event.GetType()}'"; _logger.Log(message, ex, @event); } finally { _dbSessionManager.CloseSession(); } }); t.Start(); } else { subscriber.Notify(@event); } } }
private void PublishInternal <T>(T @event, bool doAsync) { var subscribers = _subscriptionService.GetSubscriptions <T>(); foreach (var subscriber in subscribers) { if (doAsync && subscriber.IsAsynchronous) { var t = new Thread(() => { subscriber.Notify(@event); _dbSessionManager.CloseSession(); }); t.Start(); } else { subscriber.Notify(@event); } } }