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
a07226f849
commit
68f7dfe0d7
|
|
@ -6,6 +6,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#if WPF
|
#if WPF
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
@ -123,14 +124,13 @@ namespace MapControl
|
||||||
|
|
||||||
lock (tileQueue)
|
lock (tileQueue)
|
||||||
{
|
{
|
||||||
if (tileQueue.Count == 0)
|
if (!tileQueue.TryDequeue(out tile))
|
||||||
{
|
{
|
||||||
taskCount--;
|
taskCount--;
|
||||||
Logger?.LogDebug("Task count: {count}", taskCount);
|
Logger?.LogDebug("Task count: {count}", taskCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tile = tileQueue.Dequeue();
|
|
||||||
tileNumber = tileCount - tileQueue.Count;
|
tileNumber = tileCount - tileQueue.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,4 +233,15 @@ namespace MapControl
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
internal static class QueueExt
|
||||||
|
{
|
||||||
|
public static bool TryDequeue<T>(this Queue<T> queue, out T item) where T : class
|
||||||
|
{
|
||||||
|
item = queue.Count > 0 ? queue.Dequeue() : null;
|
||||||
|
return item != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue