Esempio n. 1
0
        public MethodProcessor(TimerEventArgs timer, TaskTimeStarted taskTimeStarted, Action <string> taskTimeEnded)
        {
            Timer           = timer;
            TaskTimeStarted = taskTimeStarted;
            TaskTimeEnded   = taskTimeEnded;

            TimerStarted = (object sender, TimerEventArgs e) => OnTimerStart(e);
            TimerChanged = (object sender, TimerEventArgs e) => OnTimerTick(e);
            TimerEnded   = (object sender, TimerEventArgs e) => OnTimerEnd(e);
        }
Esempio n. 2
0
        public DelegateProcessor(TimerEventArgs timer, TaskTimeStarted taskTimeStarted, Action <string> taskTimeEnded)
        {
            Timer         = timer;
            TimeStarted   = taskTimeStarted;
            TaskTimeEnded = taskTimeEnded;

            TimerStarted = delegate(object sender, TimerEventArgs e)
            {
                TimeStarted(e.Name, e.SecondsAmount);
            };

            TimerChanged = delegate(object sender, TimerEventArgs e)
            {
                int realSeconds = DateTime.Now.Second;
                Console.WriteLine("[{0}]:Timer: {1}: {2} seconds remaining", realSeconds, e.Name, e.SecondsAmount);
            };

            TimerEnded = delegate(object sender, TimerEventArgs e)
            {
                TaskTimeEnded(e.Name);
            };
        }
Esempio n. 3
0
 public virtual void OnTimerEnd(TimerEventArgs e)
 {
     TaskTimeEnded(e.Name);
 }
Esempio n. 4
0
        public virtual void OnTimerTick(TimerEventArgs e)
        {
            int realSeconds = DateTime.Now.Second;

            Console.WriteLine("[{0}]:Timer: {1}: {2} seconds remaining", realSeconds, e.Name, e.SecondsAmount);
        }
Esempio n. 5
0
 public virtual void OnTimerStart(TimerEventArgs e)
 {
     TaskTimeStarted(e.Name, e.SecondsAmount);
 }
Esempio n. 6
0
 /// <summary>
 /// Method which will be executed when event will be rised.
 /// </summary>
 /// <param name="sender">Event owner.</param>
 /// <param name="e">Event arguments.</param>
 public void OnTimerTimeout(object sender, TimerEventArgs e)
 {
     Console.WriteLine("Second listener job after {0} seconds.", e.Seconds);
 }
Esempio n. 7
0
 /// <summary>
 /// Raises Timeout event.
 /// </summary>
 /// <param name="sender">Event owner.</param>
 /// <param name="e">Event arguments.</param>
 protected virtual void OnTimeout(object sender, TimerEventArgs e) =>
 this.Timeout?.Invoke(sender, e);