Alex Rivera | Logout

Where is the WPF Timer control?

Asked 2011-03-23T19:18:25.373
194

Where can I find a control which is like the C# Timer Control in WPF?

Edit
Report

2 Answers

357

The usual WPF timer is the DispatcherTimer, which is not a control but used in code. It basically works the same way like the WinForms timer:

System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += dispatcherTimer_Tick;
dispatcherTimer.Interval = new TimeSpan(0,0,1);
dispatcherTimer.Start();


private void dispatcherTimer_Tick(object sender, EventArgs e)
{
  // code goes here
}

More on the DispatcherTimer can be found here

answered 2011-03-23T19:48:45.563
3

you can also use

using System.Timers;
using System.Threading;
answered 2013-07-30T13:19:18.263

Your Answer