mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Reverted request cancellation in TileImageLoader
This commit is contained in:
parent
00a885b654
commit
775d584df7
8 changed files with 35 additions and 87 deletions
|
|
@ -8,7 +8,7 @@ namespace MapControl
|
|||
{
|
||||
public partial class TileImageLoader
|
||||
{
|
||||
private static Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc, CancellationToken cancellationToken)
|
||||
private static Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc)
|
||||
{
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
||||
|
|
@ -16,18 +16,8 @@ namespace MapControl
|
|||
{
|
||||
try
|
||||
{
|
||||
var image = await loadImageFunc();
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
tile.IsPending = true;
|
||||
tcs.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
tile.SetImageSource(image);
|
||||
tcs.TrySetResult();
|
||||
}
|
||||
tile.SetImageSource(await loadImageFunc());
|
||||
tcs.TrySetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -37,7 +27,7 @@ namespace MapControl
|
|||
|
||||
if (!tile.Image.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, LoadTileImage))
|
||||
{
|
||||
tcs.TrySetCanceled(CancellationToken.None);
|
||||
tcs.TrySetCanceled();
|
||||
}
|
||||
|
||||
return tcs.Task;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue