fix 简化代码
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user