mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update TileImageLoader.cs
This commit is contained in:
parent
d4119395c5
commit
575f372a80
|
|
@ -71,6 +71,7 @@ namespace MapControl
|
|||
public static int MaxLoadTasks { get; set; } = 4;
|
||||
|
||||
private readonly Queue<Tile> tileQueue = new Queue<Tile>();
|
||||
private int tileCount;
|
||||
private int taskCount;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -93,7 +94,8 @@ namespace MapControl
|
|||
tileQueue.Enqueue(tile);
|
||||
}
|
||||
|
||||
var tileCount = tileQueue.Count;
|
||||
tileCount = tileQueue.Count;
|
||||
|
||||
var maxTasks = Math.Min(tileCount, MaxLoadTasks);
|
||||
|
||||
while (taskCount < maxTasks)
|
||||
|
|
@ -101,7 +103,7 @@ namespace MapControl
|
|||
taskCount++;
|
||||
Logger?.LogDebug("Task count: {count}", taskCount);
|
||||
|
||||
_ = Task.Run(async () => await LoadTilesFromStack(tileSource, cacheName, tileCount, progress).ConfigureAwait(false));
|
||||
_ = Task.Run(async () => await LoadTilesFromStack(tileSource, cacheName, progress).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -111,10 +113,11 @@ namespace MapControl
|
|||
lock (tileQueue)
|
||||
{
|
||||
tileQueue.Clear();
|
||||
tileCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadTilesFromStack(TileSource tileSource, string cacheName, int tileCount, IProgress<double> progress)
|
||||
private async Task LoadTilesFromStack(TileSource tileSource, string cacheName, IProgress<double> progress)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue