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