void clk_OnTick2(object sender, TickEventArgs args) { while (args.timeLeft == 0) { Console.WriteLine("闹钟铃声响起"); args.timeLeft = -1; } }
void clk_OnTick(object sender, TickEventArgs args) { while (args.timeLeft > 0) { Console.WriteLine("ticking...剩余时间:{0}", args.timeLeft); System.Threading.Thread.Sleep(1000); args.timeLeft -= 1; } }
public void Tick(int tleft) { Console.WriteLine("开始倒计时:"); TickEventArgs args = new TickEventArgs() { timeLeft = tleft }; OnTick(this, args); }