Update TileImageLoader.cs

This commit is contained in:
ClemensFischer 2025-08-25 21:48:38 +02:00
parent a07226f849
commit 68f7dfe0d7

View file

@ -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
} }