From d80c007cb9395db3f6ff2d1bffba92918162b453 Mon Sep 17 00:00:00 2001 From: Geoffroy Arenou Date: Tue, 9 Apr 2024 10:25:41 +0200 Subject: [PATCH] Remove the Parallel.For --- .../GMap.NET.WindowsForms/TilePrefetcher.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/TilePrefetcher.cs b/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/TilePrefetcher.cs index 80a22e4dcd..6295a411b3 100644 --- a/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/TilePrefetcher.cs +++ b/ExtLibs/GMap.NET.WindowsForms/GMap.NET.WindowsForms/TilePrefetcher.cs @@ -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; /// /// form helping to prefetch tiles on local db @@ -235,7 +233,6 @@ void worker_DoWork(object sender, DoWorkEventArgs e) int countOk = 0; int retryCount = 0; - int count = 0; if(Shuffle) { @@ -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]; { @@ -272,7 +269,7 @@ void worker_DoWork(object sender, DoWorkEventArgs e) { i--; System.Threading.Thread.Sleep(1111); - return; + continue; } else { @@ -280,14 +277,13 @@ void worker_DoWork(object sender, DoWorkEventArgs e) } } } - 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;