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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 public void MessageToConsole(object sender, TimerEventArgs args)
 {
     Console.WriteLine("I'm first. Ticks = {0}", args.Ticks);
 }
예제 #4
0
 protected virtual void OnTimeIsOver(TimerEventArgs e)
 {
     TimeIsOver.Invoke(this, e);
 }