mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-08 17:50:17 +01:00
Reset Tile.IsPending on request cancellation
This commit is contained in:
parent
c3386d1fbb
commit
545e49b306
|
|
@ -12,7 +12,11 @@ namespace MapControl
|
|||
{
|
||||
var image = await loadImageFunc().ConfigureAwait(false);
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
tile.IsPending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = Dispatcher.UIThread.InvokeAsync(() => tile.SetImageSource(image)); // no need to await InvokeAsync
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,8 +112,6 @@ namespace MapControl
|
|||
{
|
||||
Logger?.LogError(ex, "Failed loading tile image {zoom}/{column}/{row}", tile.ZoomLevel, tile.Column, tile.Row);
|
||||
}
|
||||
|
||||
tile.IsPending = cancellationToken.IsCancellationRequested && tile.Image == null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@ namespace MapControl
|
|||
|
||||
tcs.TrySetResult(null); // tcs.Task has completed when image is loaded
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
tile.IsPending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
tile.SetImageSource(image);
|
||||
}
|
||||
|
|
@ -33,7 +37,7 @@ namespace MapControl
|
|||
|
||||
if (!await tile.Image.Dispatcher.TryRunAsync(CoreDispatcherPriority.Low, LoadTileImage))
|
||||
{
|
||||
tcs.TrySetCanceled();
|
||||
tcs.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
|
||||
await tcs.Task;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ namespace MapControl
|
|||
{
|
||||
var image = await loadImageFunc().ConfigureAwait(false);
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
tile.IsPending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = tile.Image.Dispatcher.InvokeAsync(() => tile.SetImageSource(image)); // no need to await InvokeAsync
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@ namespace MapControl
|
|||
|
||||
tcs.TrySetResult(); // tcs.Task has completed when image is loaded
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
tile.IsPending = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
tile.SetImageSource(image);
|
||||
}
|
||||
|
|
@ -33,7 +37,7 @@ namespace MapControl
|
|||
|
||||
if (!tile.Image.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, LoadTileImage))
|
||||
{
|
||||
tcs.TrySetCanceled();
|
||||
tcs.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
|
||||
return tcs.Task;
|
||||
|
|
|
|||
Loading…
Reference in a new issue