void Clock_Alarm(object sender, ClockEventArgs args) { if (args.CurrentHour == args.SetHour && args.CurrentMinute == args.SetMinute && args.CurrentSecond == args.SetSecond) { Console.Write("闹钟正在响铃!"); } else { Console.Write("闹钟未到响铃时刻!"); } }
public void SClick(int Hour, int Minute, int Second) { Console.Write($"现在是{Hour}时{Minute}分{Second}秒"); ClockEventArgs args1 = new ClockEventArgs() { CurrentHour = Hour, CurrentMinute = Minute, CurrentSecond = Second }; Alarm(this, args1); }
public void Click(int Hour, int Minute, int Second) { Console.Write($"现在是{Hour}时{Minute}分{Second}秒"); ClockEventArgs args = new ClockEventArgs() { CurrentHour = Hour, CurrentMinute = Minute, CurrentSecond = Second }; while (true) { Tick(this, args); System.Threading.Thread.Sleep(1000); } }
public void SClick(int Hour, int Minute, int Second) { //System.Timers.Timer t = new System.Timers.Timer(1000); Console.Write($"现在是{Hour}时{Minute}分{Second}秒"); ClockEventArgs args1 = new ClockEventArgs() { CurrentHour = Hour, CurrentMinute = Minute, CurrentSecond = Second }; //触发Alarm事件 Alarm(this, args1); }
void Clock_Tick(object sender, ClockEventArgs args) { Console.Write("闹钟正在走时!"); }