diff --git a/Directory.Build.props b/Directory.Build.props
index b53572dd..78880c07 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
XAML Map Control
Clemens Fischer
Copyright © 2025 Clemens Fischer
- 14.0.0
+ 14.1.0
$(Version)
..\..\MapControl.snk
true
diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs
index 7622c258..228e7276 100644
--- a/MapControl/Shared/MapImageLayer.cs
+++ b/MapControl/Shared/MapImageLayer.cs
@@ -53,7 +53,7 @@ namespace MapControl
DependencyPropertyHelper.Register(nameof(LoadingProgress), 1d);
private readonly Progress loadingProgress;
- private readonly DispatcherTimer updateTimer;
+ private readonly UpdateTimer updateTimer;
private bool updateInProgress;
public MapImageLayer()
@@ -62,7 +62,7 @@ namespace MapControl
loadingProgress = new Progress(p => SetValue(LoadingProgressProperty, p));
- updateTimer = new DispatcherTimer { Interval = UpdateInterval };
+ updateTimer = new UpdateTimer { Interval = UpdateInterval };
updateTimer.Tick += async (s, e) => await UpdateImageAsync();
}
@@ -164,15 +164,7 @@ namespace MapControl
}
else
{
- if (!UpdateWhileViewportChanging)
- {
- updateTimer.Stop();
- }
-
- if (!updateTimer.IsEnabled)
- {
- updateTimer.Start();
- }
+ updateTimer.Run(!UpdateWhileViewportChanging);
}
}
@@ -207,9 +199,9 @@ namespace MapControl
updateInProgress = false;
}
- else if (!updateTimer.IsEnabled) // update on next timer tick
+ else // update on next timer tick
{
- updateTimer.Start();
+ updateTimer.Run();
}
}
diff --git a/MapControl/Shared/MapTilePyramidLayer.cs b/MapControl/Shared/MapTilePyramidLayer.cs
index b1c9790d..ebb5b744 100644
--- a/MapControl/Shared/MapTilePyramidLayer.cs
+++ b/MapControl/Shared/MapTilePyramidLayer.cs
@@ -58,7 +58,7 @@ namespace MapControl
DependencyPropertyHelper.Register(nameof(LoadingProgress), 1d);
private readonly Progress loadingProgress;
- private readonly DispatcherTimer updateTimer;
+ private readonly UpdateTimer updateTimer;
private ITileImageLoader tileImageLoader;
private MapBase parentMap;
@@ -68,7 +68,7 @@ namespace MapControl
loadingProgress = new Progress(p => SetValue(LoadingProgressProperty, p));
- updateTimer = new DispatcherTimer { Interval = UpdateInterval };
+ updateTimer = new UpdateTimer { Interval = UpdateInterval };
updateTimer.Tick += (s, e) => Update(false);
MapPanel.SetRenderTransform(this, new MatrixTransform());
@@ -185,10 +185,7 @@ namespace MapControl
parentMap.ViewportChanged += OnViewportChanged;
}
- if (!updateTimer.IsEnabled)
- {
- updateTimer.Start();
- }
+ updateTimer.Run();
}
}
@@ -207,7 +204,6 @@ namespace MapControl
protected void CancelLoadTiles()
{
TileImageLoader.CancelLoadTiles();
-
ClearValue(LoadingProgressProperty);
}
@@ -218,7 +214,6 @@ namespace MapControl
private void Update(bool resetTiles)
{
updateTimer.Stop();
-
UpdateTiles(resetTiles);
}
@@ -231,16 +226,7 @@ namespace MapControl
else
{
SetRenderTransform();
-
- if (!UpdateWhileViewportChanging)
- {
- updateTimer.Stop();
- }
-
- if (!updateTimer.IsEnabled)
- {
- updateTimer.Start();
- }
+ updateTimer.Run(!UpdateWhileViewportChanging);
}
}
}
diff --git a/MapControl/Shared/UpdateTimer.cs b/MapControl/Shared/UpdateTimer.cs
new file mode 100644
index 00000000..8fcd78c4
--- /dev/null
+++ b/MapControl/Shared/UpdateTimer.cs
@@ -0,0 +1,28 @@
+#if WPF
+using System.Windows.Threading;
+#elif UWP
+using Windows.UI.Xaml;
+#elif WINUI
+using Microsoft.UI.Xaml;
+#elif AVALONIA
+using Avalonia.Threading;
+#endif
+
+namespace MapControl
+{
+ internal class UpdateTimer : DispatcherTimer
+ {
+ public void Run(bool restart = false)
+ {
+ if (restart)
+ {
+ Stop();
+ }
+
+ if (!IsEnabled)
+ {
+ Start();
+ }
+ }
+ }
+}