mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-05-07 13:37:47 +00:00
Renamed Timer helper class
This commit is contained in:
parent
085a9b6181
commit
a79d26aa43
2 changed files with 4 additions and 4 deletions
47
MapControl/Shared/DispatcherTimerHelper.cs
Normal file
47
MapControl/Shared/DispatcherTimerHelper.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml;
|
||||
#elif WINUI
|
||||
global using DispatcherTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
|
||||
using Microsoft.UI.Xaml;
|
||||
#endif
|
||||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
internal static class DispatcherTimerHelper
|
||||
{
|
||||
public static DispatcherTimer CreateTimer(this DependencyObject obj, TimeSpan interval)
|
||||
{
|
||||
#if WINUI
|
||||
var timer = obj.DispatcherQueue.CreateTimer();
|
||||
#else
|
||||
var timer = new DispatcherTimer();
|
||||
#endif
|
||||
timer.Interval = interval;
|
||||
return timer;
|
||||
}
|
||||
|
||||
public static void Run(this DispatcherTimer timer, bool restart = false)
|
||||
{
|
||||
if (restart)
|
||||
{
|
||||
timer.Stop();
|
||||
}
|
||||
#if WINUI
|
||||
if (!timer.IsRunning)
|
||||
#else
|
||||
if (!timer.IsEnabled)
|
||||
#endif
|
||||
{
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue