mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Added optional image request cancellation
This commit is contained in:
parent
ebd90f5a45
commit
34fda668c9
6 changed files with 98 additions and 27 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
|
|
@ -6,11 +7,14 @@ 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 image = await loadImageFunc().ConfigureAwait(false);
|
||||
|
||||
_ = tile.Image.Dispatcher.InvokeAsync(() => tile.SetImageSource(image)); // no need to await InvokeAsync
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
_ = tile.Image.Dispatcher.InvokeAsync(() => tile.SetImageSource(image)); // no need to await InvokeAsync
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue