Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close (auto hide) WPF window after 10 sec using timer [closed]

Tags:

c#

wpf

How to close (auto hide) WPF window after 10 sec using a timer in C#?

like image 312
Shashank Avatar asked Jul 30 '12 10:07

Shashank


1 Answers

Do it this way:

private void StartCloseTimer()
{
    DispatcherTimer timer = new DispatcherTimer();
    timer.Interval = TimeSpan.FromSeconds(10d);
    timer.Tick += TimerTick;
    timer.Start();
}

private void TimerTick(object sender, EventArgs e)
{
    DispatcherTimer timer = (DispatcherTimer)sender;
    timer.Stop();
    timer.Tick -= TimerTick;
    Close();
}
like image 103
Clemens Avatar answered Oct 03 '22 21:10

Clemens