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
c84049bf82
commit
7fbbf66acb
|
|
@ -75,32 +75,32 @@ namespace MapControl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TileSource TileSource { get; private set; }
|
public TileSource TileSource { get; private set; }
|
||||||
|
|
||||||
private TileQueue pendingTiles;
|
private TileQueue unloadedTiles;
|
||||||
private int progressTotal;
|
private int progressTotal;
|
||||||
private int progressLoaded;
|
private int progressLoaded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads all pending tiles from the tiles collection.
|
/// Loads all unloaded 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>
|
||||||
public Task LoadTiles(IEnumerable<Tile> tiles, TileSource tileSource, string cacheName)
|
public Task LoadTiles(IEnumerable<Tile> tiles, TileSource tileSource, string cacheName)
|
||||||
{
|
{
|
||||||
pendingTiles?.Cancel();
|
unloadedTiles?.Cancel();
|
||||||
|
|
||||||
TileSource = tileSource;
|
TileSource = tileSource;
|
||||||
|
|
||||||
if (tileSource != null)
|
if (tileSource != null)
|
||||||
{
|
{
|
||||||
pendingTiles = new TileQueue(tiles);
|
unloadedTiles = new TileQueue(tiles);
|
||||||
|
|
||||||
var numTasks = Math.Min(pendingTiles.Count, MaxLoadTasks);
|
var numTasks = Math.Min(unloadedTiles.Count, MaxLoadTasks);
|
||||||
|
|
||||||
if (numTasks > 0)
|
if (numTasks > 0)
|
||||||
{
|
{
|
||||||
if (Progress != null)
|
if (Progress != null)
|
||||||
{
|
{
|
||||||
progressTotal = pendingTiles.Count;
|
progressTotal = unloadedTiles.Count;
|
||||||
progressLoaded = 0;
|
progressLoaded = 0;
|
||||||
Progress.Report(0d);
|
Progress.Report(0d);
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.WhenAll(Enumerable.Range(0, numTasks).Select(
|
return Task.WhenAll(Enumerable.Range(0, numTasks).Select(
|
||||||
_ => Task.Run(() => LoadPendingTiles(pendingTiles, tileSource, cacheName))));
|
_ => Task.Run(() => LoadPendingTiles(unloadedTiles, tileSource, cacheName))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue