mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
41 lines
872 B
C#
41 lines
872 B
C#
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|||
|
|
// © 2021 Clemens Fischer
|
|||
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|||
|
|
|
|||
|
|
using System;
|
|||
|
|
#if UWP
|
|||
|
|
using Windows.UI.Xaml;
|
|||
|
|
#else
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Threading;
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
namespace MapControl
|
|||
|
|
{
|
|||
|
|
internal static class Timer
|
|||
|
|
{
|
|||
|
|
public static DispatcherTimer CreateTimer(this DependencyObject obj, TimeSpan interval)
|
|||
|
|
{
|
|||
|
|
var timer = new DispatcherTimer
|
|||
|
|
{
|
|||
|
|
Interval = interval
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
return timer;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void Run(this DispatcherTimer timer, bool restart = false)
|
|||
|
|
{
|
|||
|
|
if (restart)
|
|||
|
|
{
|
|||
|
|
timer.Stop();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!timer.IsEnabled)
|
|||
|
|
{
|
|||
|
|
timer.Start();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|