The following code snippet using DispatcherTimer should provide equivalent functionality that performs a callback in the user interface thread.
using Windows.UI.Xaml; public class Foo { DispatcherTimer dispatcherTimer; public void StartTimers() { dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 1); }
When there is no need to update the user interface thread and you only need a timer, you can use ThreadPoolTimer , for example
using Windows.System.Threading; public class Foo { ThreadPoolTimer timer; public void StartTimers() { timer = ThreadPoolTimer.CreatePeriodicTimer(TimerElapsedHandler, new TimeSpan(0, 0, 1)); } private void TimerElapsedHandler(ThreadPoolTimer timer) {
source share