private void NotifyListeners(Event evt, Func <string, IList <Listener> > listenersFn) { evt.CurrentTarget = _target; lock (_getLockObject()) { var listeners = listenersFn(evt.Type); // ReSharper disable once ForCanBeConvertedToForeach, to avoid 'collection was modified' exception for (var i = 0; i < listeners.Count; i++) { var listener = listeners[i]; if (listener.Options != null && listener.Options.Passive) { evt.PreventDefaultDeprecated = true; } try { listener.Handler(evt); } catch (Exception e) { HandlerException?.Invoke(e); } finally { evt.PreventDefaultDeprecated = false; } if (listener.Options != null && listener.Options.Once) { RemoveEventListener(evt.Type, listener.Handler, listener.Options); } } } }
public void OnHandlerException(object sender, HandlerExceptionEventArgs args) { HandlerException.Invoke(sender, args); }