protected virtual void OnTimer(object sender, TimerEventArgs args) { var exceptions = new Queue<Exception>(); var arrayEventHandler = Timer.GetInvocationList(); foreach (var itemEventHandler in arrayEventHandler) { var eventHandler = (TimerEventHandler) itemEventHandler; try { eventHandler(sender, args); } catch (Exception e) { exceptions.Enqueue(e); } } if (exceptions.Count > 0) throw new AggregateException(exceptions); }
protected virtual void OnTimer(object sender, TimerEventArgs args) { var exceptions = new Queue <Exception>(); var arrayEventHandler = Timer.GetInvocationList(); foreach (var itemEventHandler in arrayEventHandler) { var eventHandler = (TimerEventHandler)itemEventHandler; try { eventHandler(sender, args); } catch (Exception e) { exceptions.Enqueue(e); } } if (exceptions.Count > 0) { throw new AggregateException(exceptions); } }
public void MessageToConsole(object sender, TimerEventArgs args) { Console.WriteLine("I'm first. Ticks = {0}", args.Ticks); }
protected virtual void OnTimeIsOver(TimerEventArgs e) { TimeIsOver.Invoke(this, e); }