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