public void Alarm(int hour, int minute, int second) { TimeEventArgs myClock = new TimeEventArgs(hour, minute, second); while (true) { DateTime dt = DateTime.Now; if (dt.Hour.Equals(hour) && dt.Minute.Equals(minute) && dt.Second.Equals(second)) { break; } } AlarmClock(this, myClock); }
static void Clock_alarm(object sender, TimeEventArgs e) { Console.WriteLine("时间到了!!!"); }
//事件的处理方法 static void showtime(object sender, TimeEventArgs e) { Console.WriteLine("这个时候闹钟就应该发出奇怪的声音了"); }