WPF单线程定时器 简单实例
时间:2014-05-09 03:27:00
收藏:0
阅读:366
//窗体加载完毕 void MyMessageBox_Loaded(object sender, RoutedEventArgs e) { //启动定时期倒计时,多线程计时 //System.Threading.Timer timer; //启动单线程计时 System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += ShowTimeTick; timer.Start(); } //定时修改计时时间 private void ShowTimeTick(object sender, EventArgs e) { timeTick.Content = TimeSpan + "秒后,自动关闭..."; if (TimeSpan == 0) { this.Close(); } TimeSpan--; }
评论(0)