Update TileImageLoader.cs

This commit is contained in:
ClemensFischer 2025-01-20 19:28:59 +01:00
parent 507bc93d99
commit 115525cbfc

View file

@ -91,8 +91,15 @@ namespace MapControl
progress?.Report((double)(tileCount - tileStack.Count) / tileCount);
try
{
await LoadTileAsync(tile, tileSource, cacheName).ConfigureAwait(false);
}
catch (Exception ex)
{
Debug.WriteLine($"{nameof(TileImageLoader)}: {tile.ZoomLevel}/{tile.Column}/{tile.Row}: {ex.Message}");
}
}
}
for (int i = 0; i < taskCount; i++)
@ -107,10 +114,9 @@ namespace MapControl
private static async Task LoadTileAsync(Tile tile, TileSource tileSource, string cacheName)
{
// Both tileSource.LoadImageAsync calls below are executed in the UI thread in WinUI and UWP.
// Pass tileSource.LoadImageAsync calls to platform-specific method
// LoadTileAsync(Tile, Func<Task<ImageSource>>) for execution on the UI thread in WinUI/UWP.
try
{
if (string.IsNullOrEmpty(cacheName))
{
await LoadTileAsync(tile, () => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel)).ConfigureAwait(false);
@ -130,11 +136,6 @@ namespace MapControl
}
}
}
catch (Exception ex)
{
Debug.WriteLine($"{nameof(TileImageLoader)}: {tile.ZoomLevel}/{tile.Column}/{tile.Row}: {ex.Message}");
}
}
private static async Task<byte[]> LoadCachedBufferAsync(Tile tile, Uri uri, string cacheName)
{