/// <summary> /// The method counts down the specified number of seconds. /// </summary> /// <param name="nameOfEvent"> /// An event up to which counts the number of seconds. /// </param> /// <param name="time"> /// Time to event. /// </param> public void StartClock(int time, string nameOfEvent = null) { System.Timers.Timer timer = new System.Timers.Timer(time * 1000); _timers[timer] = new ClockEventArgs(nameOfEvent, time); timer.Elapsed += TimerOnElapsed; timer.AutoReset = false; timer.Enabled = true; }
private void TimeIsOut(object sender, ClockEventArgs eventArgs) { Console.WriteLine($"{eventArgs.Time} seconds have expired."); }
protected virtual void OnTimeOut(object sender, ClockEventArgs e) { TimeOut?.Invoke(this, e); }