Skip to content

Commit

Permalink
Remove the Parallel.For
Browse files Browse the repository at this point in the history
  • Loading branch information
Godeffroy committed Apr 9, 2024
1 parent b88d45c commit d80c007
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ namespace GMap.NET
using GMap.NET.MapProviders;
using System.Threading;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;
using System.Drawing;
using System.Threading.Tasks;

/// <summary>
/// form helping to prefetch tiles on local db
Expand Down Expand Up @@ -235,7 +233,6 @@ void worker_DoWork(object sender, DoWorkEventArgs e)

int countOk = 0;
int retryCount = 0;
int count = 0;

if(Shuffle)
{
Expand All @@ -247,10 +244,10 @@ void worker_DoWork(object sender, DoWorkEventArgs e)
CachedTiles.Clear();
}

Parallel.For(0, all, (i, state)=>
for (int i = 0; i < all; i++)
{
if(worker.CancellationPending)
state.Break();
break;

GPoint p = list[i];
{
Expand All @@ -272,22 +269,21 @@ void worker_DoWork(object sender, DoWorkEventArgs e)
{
i--;
System.Threading.Thread.Sleep(1111);
return;
continue;
}
else
{
retryCount = 0;
}
}
}
count++;
worker.ReportProgress((int)((count + 1) * 100 / all), count + 1);
worker.ReportProgress((int)((i + 1) * 100 / all), i + 1);

if (sleep > 0)
{
System.Threading.Thread.Sleep(sleep);
}
});
}

e.Result = countOk;

Expand Down

0 comments on commit d80c007

Please sign in to comment.