mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
34 lines
834 B
C#
34 lines
834 B
C#
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
// Copyright © Clemens Fischer
|
|
// 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();
|
|
}
|
|
}
|
|
}
|
|
}
|