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,13 +1,14 @@
|
|||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class TileImageLoader
|
||||
{
|
||||
private static Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc)
|
||||
private static Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc, CancellationToken cancellationToken)
|
||||
{
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
||||
|
|
@ -19,7 +20,10 @@ namespace MapControl
|
|||
|
||||
tcs.TrySetResult(); // tcs.Task has completed when image is loaded
|
||||
|
||||
tile.SetImageSource(image);
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
tile.SetImageSource(image);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue