Example #1
0
 private void NewTime(object clock, TimeEventAgrs e)
 {
     Console.WriteLine("logger event at: {0}: {1}: {2}",
                       e.Hour.ToString(),
                       e.Minute.ToString(),
                       e.Second.ToString());
 }
Example #2
0
        public void RunClock()
        {
            while (true)
            {
                Thread.Sleep(100);
                DateTime currentTime = DateTime.Now;

                if (currentTime.Second != this.second)
                {
                    TimeEventAgrs timeEventAgrs = new TimeEventAgrs()
                    {
                        Hour   = currentTime.Hour,
                        Minute = currentTime.Minute,
                        Second = currentTime.Second
                    };

                    if (TimeChanged != null)
                    {
                        TimeChanged(this, timeEventAgrs);
                    }

                    this.second = currentTime.Second;
                    this.minute = currentTime.Minute;
                    this.hour   = currentTime.Hour;
                }
            }
        }