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
a2c472162b
commit
bd9e7866f5
|
|
@ -58,7 +58,7 @@ namespace MapControl
|
||||||
private TileQueue pendingTiles;
|
private TileQueue pendingTiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads all unloaded tiles from the tiles collection.
|
/// Loads all pending tiles from the tiles collection.
|
||||||
/// If tileSource.UriFormat starts with "http" and cacheName is a non-empty string,
|
/// If tileSource.UriFormat starts with "http" and cacheName is a non-empty string,
|
||||||
/// tile images will be cached in the TileImageLoader's Cache - if that is not null.
|
/// tile images will be cached in the TileImageLoader's Cache - if that is not null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -80,10 +80,11 @@ namespace MapControl
|
||||||
cacheName = null; // no tile caching
|
cacheName = null; // no tile caching
|
||||||
}
|
}
|
||||||
|
|
||||||
var tileQueue = pendingTiles; // pendingTiles may change while LoadTilesFromQueue() is running
|
|
||||||
|
|
||||||
progress?.Report(0d);
|
progress?.Report(0d);
|
||||||
|
|
||||||
|
var tileQueue = pendingTiles; // pendingTiles may change while tasks are running
|
||||||
|
var tasks = new Task[taskCount];
|
||||||
|
|
||||||
async Task LoadTilesFromQueue()
|
async Task LoadTilesFromQueue()
|
||||||
{
|
{
|
||||||
while (tileQueue.TryDequeue(out var tile))
|
while (tileQueue.TryDequeue(out var tile))
|
||||||
|
|
@ -101,7 +102,12 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.WhenAll(Enumerable.Range(0, taskCount).Select(_ => Task.Run(LoadTilesFromQueue)));
|
for (int i = 0; i < taskCount; i++)
|
||||||
|
{
|
||||||
|
tasks[i] = Task.Run(LoadTilesFromQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue