public void Process(object sender, EventEventArgs e) { if (handler == null) { lock (this) { if (handler == null) { handler = Activator.CreateInstance(handlerType) as IEventHandler; } } } handler.Process(sender, e); }
public static void RaiseEvent(object sender, EventEventArgs e) { if (HandlersByEvent.TryGetValue(e.Name, out List <WrappedHandler> handlers)) { foreach (var handler in handlers) { try { Log.Debug($"Invoke handler '{handler.Type}' for event '{e.Name}'."); handler.Process(sender, e); } catch (Exception ex) { Log.Error($"Handler '{handler}' throws exception while handling event '{e.Name}'.", ex); } } } }