fix 简化代码

This commit is contained in:
2024-12-12 11:54:18 +08:00
parent 6684f07925
commit 3a6aa8ea0f
3 changed files with 36 additions and 66 deletions

View File

@@ -4,6 +4,13 @@ public static class ParallelExtensions
{
public static void ParallelForEach<T>(this IEnumerable<T> source, Action<T> action)
{
#if DEBUG
foreach (var item in source)
{
action.Invoke(item);
}
#else
Parallel.ForEach(source, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, action);
#endif
}
}