public void OnAfterWithHistory(S sender, T eventArgs, S historyData) { EventHandlerWithHistory <S, T> eventHandlerWithHistory = EventBus <S, T> .Handlers[this.EventHandlerKey_AfterWithHistory] as EventHandlerWithHistory <S, T>; if (eventHandlerWithHistory != null) { System.Delegate[] invocationList = eventHandlerWithHistory.GetInvocationList(); System.Delegate[] array = invocationList; for (int i = 0; i < array.Length; i++) { EventHandlerWithHistory <S, T> eventHandlerWithHistory2 = (EventHandlerWithHistory <S, T>)array[i]; try { eventHandlerWithHistory2.BeginInvoke(sender, eventArgs, historyData, null, null); } catch (System.Exception exception) { LoggerFactory.GetLogger().Log(LogLevel.Error, exception, "执行触发含历史数据操作执行后事件时发生异常"); } } } }
/// <summary> /// 触发含历史数据操作执行后事件 /// </summary> /// <param name="sender">触发事件的对象</param> /// <param name="eventArgs">事件参数</param> /// <param name="historyData">触发事件对象的历史数据(例如S从一种状态变更为另一种状态,historyData指变更前的对象)</param> public void OnAfterWithHistory(S sender, T eventArgs, S historyData) { EventHandlerWithHistory <S, T> handler = Handlers[EventHandlerKey_AfterWithHistory] as EventHandlerWithHistory <S, T>; if (handler != null) { //获取事件中的多路委托列表 Delegate[] delegateArray = handler.GetInvocationList(); foreach (EventHandlerWithHistory <S, T> dele in delegateArray) { try { dele.BeginInvoke(sender, eventArgs, historyData, null, null); } catch (Exception e) { LoggerFactory.GetLogger().Log(LogLevel.Error, e, "执行触发含历史数据操作执行后事件时发生异常"); } } } }