mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-08 16:05:50 +00:00
Image loading with cancellation
This commit is contained in:
parent
79b9e9d33d
commit
ebd90f5a45
3 changed files with 53 additions and 69 deletions
|
|
@ -171,12 +171,7 @@ namespace MapControl
|
|||
protected async Task UpdateImageAsync()
|
||||
{
|
||||
updateTimer.Stop();
|
||||
|
||||
if (cancellationTokenSource != null)
|
||||
{
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = null;
|
||||
}
|
||||
cancellationTokenSource?.Cancel();
|
||||
|
||||
if (ParentMap != null && ParentMap.ActualWidth > 0d && ParentMap.ActualHeight > 0d)
|
||||
{
|
||||
|
|
@ -187,9 +182,12 @@ namespace MapControl
|
|||
|
||||
var boundingBox = ParentMap.ViewRectToBoundingBox(new Rect(x, y, width, height));
|
||||
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
ImageSource image;
|
||||
|
||||
var image = await GetImageAsync(boundingBox, loadingProgress, cancellationTokenSource.Token);
|
||||
using (cancellationTokenSource = new CancellationTokenSource())
|
||||
{
|
||||
image = await GetImageAsync(boundingBox, loadingProgress, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
cancellationTokenSource = null;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue