Ruben 2 anni fa
parent
commit
3f3f80ad8a
1 ha cambiato i file con 3 aggiunte e 4 eliminazioni
  1. 3 4
      src/PicView/ChangeImage/PreLoader.cs

+ 3 - 4
src/PicView/ChangeImage/PreLoader.cs

@@ -198,7 +198,7 @@ internal static class PreLoader
             Trace.WriteLine($"\nPreLoading started at {nextStartingIndex}\n");
 #endif
 
-        await Parallel.ForAsync(0, PositiveIterations + NegativeIterations, source.Token, (i, loopState) =>
+        await Parallel.ForAsync(0, PositiveIterations + NegativeIterations, source.Token, async (i, loopState) =>
         {
             try
             {
@@ -209,7 +209,7 @@ internal static class PreLoader
             }
             catch (Exception)
             {
-                return ValueTask.CompletedTask;
+                return;
             }
 
             int index;
@@ -222,8 +222,7 @@ internal static class PreLoader
                 index = (nextStartingIndex + i) % Pics.Count;
             }
 
-            _ = AddAsync(index).ConfigureAwait(false);
-            return ValueTask.CompletedTask;
+            await AddAsync(index).ConfigureAwait(false);
         });
 
         var thread = Thread.CurrentThread;