Update GroundOverlay.cs

This commit is contained in:
ClemensFischer 2025-09-09 13:47:10 +02:00
parent 9a3da275c0
commit ee450e1a56

View file

@ -162,22 +162,24 @@ namespace MapControl
{
var imageOverlays = ReadImageOverlays(document);
var semaphore = new SemaphoreSlim(MaxLoadTasks);
var tasks = imageOverlays.Select(async imageOverlay =>
using (var semaphore = new SemaphoreSlim(MaxLoadTasks))
{
await semaphore.WaitAsync();
try
{
await loadFunc(imageOverlay); // no more than MaxLoadTasks parallel executions here
}
finally
{
semaphore.Release();
}
});
var tasks = imageOverlays.Select(
async imageOverlay =>
{
await semaphore.WaitAsync();
try
{
await loadFunc(imageOverlay); // no more than MaxLoadTasks parallel executions here
}
finally
{
semaphore.Release();
}
});
await Task.WhenAll(tasks);
await Task.WhenAll(tasks);
}
return imageOverlays;
}