public void NewTime(object clock, TimeEventArgs e) { Console.WriteLine("{0}:{1}:{2}", e.Hour.ToString(), e.Minute.ToString(), e.Second.ToString()); }
public void RunClock() { while (true) { Thread.Sleep(100); DateTime currentTime = DateTime.Now; if(currentTime.Second != this.second) { TimeEventArgs timeEventArgs = new TimeEventArgs() { Hour = currentTime.Hour, Minute = currentTime.Minute, Second = currentTime.Second }; if(TimeChanged != null) { TimeChanged(this, timeEventArgs); } this.hour = currentTime.Hour; this.minute = currentTime.Minute; this.second = currentTime.Second; } } }