//监听时间 public void WatchTime() { TimeOfNow time = new TimeOfNow(); int Hour = time.Today.Hour; int Minute = time.Today.Minute; if (Hour == AlarmHour && Minute == AlarmMinute) { time.Today = DateTime.Now; alarm(this, time); } else { System.Threading.Thread.Sleep(10000); WatchTime(); } }
static void myAlarm(object sender, TimeOfNow t) { Console.WriteLine(t.Today.Hour + ":" + t.Today.Minute + " 到了!!"); }