Update the UI from a periodic timer
November 9, 2016 ยท View on GitHub
Performs the specified action at the specified interval in minutes.
using System;
using Windows.UI.Xaml;
public static void StartTimer(int intervalInMinutes, Action action)
{
var timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, intervalInMinutes, 0);
timer.Tick += (s, e) => action();
timer.Start();
}
Usage
StartTimer(5, () =>
{
// Do something every five minutes.
});
See also
DispatcherTimer class
Lambda expressions (anonymous methods using the "=>" syntax)
The TrafficApp sample uses this method to update location travel info and freshness timestamps.