2021年3月11日星期四

Parallel.ForEach and conditional with normal loop in .NET

Will the following below do parallelism at 5 for 500 items, but a normal loop (no performance hit) with 1 item. I dont want the performance hit of using Parallel, if there is one, when doing 1 item at a time.

 Parallel.ForEach(scheduledMatchups, new ParallelOptions              {                  MaxDegreeOfParallelism = scheduledMatchups.Count() > 500 ? 5 : 1              },     gridItem =>              {  // Process  });  
https://stackoverflow.com/questions/66593433/parallel-foreach-and-conditional-with-normal-loop-in-net March 12, 2021 at 10:40AM

没有评论:

发表评论