Added optional image request cancellation

This commit is contained in:
ClemensFischer 2025-08-20 16:44:48 +02:00
parent ebd90f5a45
commit 34fda668c9
6 changed files with 98 additions and 27 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Windows.UI.Core;
using Windows.UI.Xaml.Media;
@ -7,7 +8,7 @@ namespace MapControl
{
public partial class TileImageLoader
{
private static async Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc)
private static async Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc, CancellationToken cancellationToken)
{
var tcs = new TaskCompletionSource<object>();
@ -19,7 +20,10 @@ namespace MapControl
tcs.TrySetResult(null); // tcs.Task has completed when image is loaded
tile.SetImageSource(image);
if (!cancellationToken.IsCancellationRequested)
{
tile.SetImageSource(image);
}
}
catch (Exception ex)
{