wpf定时关闭弹窗
定时关闭窗口
public MainWindow()
{
StartUpGif startUpGif = new StartUpGif();
StartCloseTimer();
startUpGif.ShowDialog();
}
private void StartCloseTimer()
{
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(7); // 7秒
timer.Tick += TimerTick;
timer.Start();
}
private void TimerTick(object sender, EventArgs e)
{
DispatcherTimer timer = (DispatcherTimer)sender;
timer.Stop();
timer.Tick -= TimerTick; // 取消注册
startUpGif.Close();
}

浙公网安备 33010602011771号