Beispiel #1
0
 public void Run()
 {
     while (true)
     {
         if (this.second < 59)
         {
             this.second++;
         }
         else
         {
             this.second = 0;
             this.minute++;
             if (this.minute == 60)
             {
                 this.minute = 0;
                 this.hour   = (this.hour + 1) % 24;
             }
         }
         TimeArgs CurrentTime = new TimeArgs()
         {
             Hour = hour, Minute = minute, Second = second
         };                                                                                      //当前时间
         if (this.hour == this.aHour && this.minute == this.aMinute && this.second == this.aSecond)
         {
             OnAlarm(this, CurrentTime);
         }
         else
         {
             OnTick(this, CurrentTime);
         }
         System.Threading.Thread.Sleep(1000);
     }
 }
Beispiel #2
0
 void OnAlarm(object sender, TimeArgs args)
 {
     Console.WriteLine("Alarm!:[" + args.Hour + ":" + args.Minute + ":" + args.Second + "]");
 }