예제 #1
0
        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);
        }
예제 #2
0
파일: EventCore.cs 프로젝트: weikety/ECode
        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);
                    }
                }
            }
        }