//窗体加载完毕
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(, , );
timer.Tick += ShowTimeTick;
timer.Start();
} //定时修改计时时间
private void ShowTimeTick(object sender, EventArgs e)
{
timeTick.Content = TimeSpan + "秒后,自动关闭...";
if (TimeSpan == )
{
this.Close();
}
TimeSpan--;
}