WPF introduces a new timer other than System.Timers.Timer called DispatcherTimer.
Here is a way to use Dispatcher Timer-
private DispatcherTimer timer;
public Window1()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Window1_Loaded);
}
void Window1_Loaded(object sender, RoutedEventArgs e)
{
timer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(10)};
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
//Do your operation here
}
Hope this helps
Happy Programming!!!
0 Responses to "WPF Timer"
Post a Comment