Closed ivan-menshikov closed 2 years ago
Does .NET Parallel.ForEachAsync behave the same ?
AFAIK there is no overload of Parallel.ForEachAsync returning Task<T[]> https://github.com/dotnet/runtime/blob/53d1d2c6ec322fd5eb3351982107d389c182ad46/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.ForEachAsync.cs
I see, we are talking about public static async Task<TResult[]> ForEachAsync<T, TResult>
.
If I understand correctly instead of ConcurrentQueue
, we can use an array:
https://github.com/rsdn/CodeJam/blob/master/CodeJam.Main/Threading/TaskHelper.ForEachAsync.cs#L148
WDYT ?
One would expect ForEachAsync to behave like Task.WhenAll and return the results in the same order as the source sequence. This should at least be mentioned in the docs.