mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +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 async Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc, CancellationToken cancellationToken)
|
||||
private static async Task LoadTileImage(Tile tile, Func<Task<ImageSource>> loadImageFunc)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
||||
|
|
@ -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(null);
|
||||
}
|
||||
tile.SetImageSource(await loadImageFunc());
|
||||
tcs.TrySetResult(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -37,7 +27,7 @@ namespace MapControl
|
|||
|
||||
if (!await tile.Image.Dispatcher.TryRunAsync(CoreDispatcherPriority.Low, LoadTileImage))
|
||||
{
|
||||
tcs.TrySetCanceled(CancellationToken.None);
|
||||
tcs.TrySetCanceled();
|
||||
}
|
||||
|
||||
await tcs.Task;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue