2022-01-12 23:56:05 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2022-01-14 20:22:56 +01:00
|
|
|
|
// © 2022 Clemens Fischer
|
2022-01-12 23:56:05 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using Microsoft.UI.Dispatching;
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
internal static class Timer
|
|
|
|
|
|
{
|
|
|
|
|
|
public static DispatcherQueueTimer CreateTimer(this DependencyObject obj, TimeSpan interval)
|
|
|
|
|
|
{
|
|
|
|
|
|
var timer = obj.DispatcherQueue.CreateTimer();
|
|
|
|
|
|
timer.Interval = interval;
|
|
|
|
|
|
return timer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Run(this DispatcherQueueTimer timer, bool restart = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (restart)
|
|
|
|
|
|
{
|
|
|
|
|
|
timer.Stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!timer.IsRunning)
|
|
|
|
|
|
{
|
|
|
|
|
|
timer.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|