Example #1
0
        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.second = currentTime.Second;
                    this.minute = currentTime.Minute;
                    this.hour   = currentTime.Hour;
                }
            }
        }
Example #2
0
 public void NewTime(object theClock, TimeEventArgs e)
 {
     Console.WriteLine("{0}:{1}:{2}",
                       e.Hour.ToString(),
                       e.Minute.ToString(),
                       e.Second.ToString());
 }