В основном я хочу, чтобы объект таймера диспетчера выполнялся только один раз.
Итак, у меня есть базовый код:
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 4);
dispatcherTimer.Start();
Затем внутри события click:
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
this.Visibility = System.Windows.Visibility.Visible;
// Now stop timer execution.. or kill the timer object
}
Как я могу остановить таймер или убить объект после этого выполнения?