You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static Task ForEachAsync<T>(
this IEnumerable<T> source, int dop, Func<T, Task> body)
{
return Task.WhenAll(
from partition in Partitioner.Create(source).GetPartitions(dop)
select Task.Run(async delegate {
using (partition)
while (partition.MoveNext())
await body(partition.Current).ContinueWith(t =>
{
//observe exceptions
});
}));
}
Your library has a few ForEachAsyncExtensions and ParallelForEachExtensions, that seems to do similar things.
It will be good if you add clarification in readme.md or wiki what is the difference between ForEachAsyncExtensions and ParallelForEachExtensions. It also will be good to clarify how ParallelForEachExtensions are different from MS Parallel.ForEach.
Also I wish to know your opinion, is mentioned above ForEachAsync good enough, or there are some limitations of this approach that some methods of your library addresses
The text was updated successfully, but these errors were encountered:
Hi, I added more info to the Readme - see pt.9 to describe the difference. The MS version of Parallel.ForEach does not work with async-enumerable collections and async delegates, what leads to thread-blocking calls if you try to use it - that's what this library solves, avoids such blocking IO calls with IAsyncEnumerable and async delegates.
Hope that answers your questions.
The thread https://stackoverflow.com/questions/11564506/nesting-await-in-parallel-foreach/11565531#11565531 has an answer suggested to use Task.WhenAll to run multiple (degreeOfParallel) asynchronous tasks in parallel, not waiting until previous task is completed.
Your library has a few ForEachAsyncExtensions and ParallelForEachExtensions, that seems to do similar things.
It will be good if you add clarification in readme.md or wiki what is the difference between ForEachAsyncExtensions and ParallelForEachExtensions. It also will be good to clarify how ParallelForEachExtensions are different from MS Parallel.ForEach.
Also I wish to know your opinion, is mentioned above ForEachAsync good enough, or there are some limitations of this approach that some methods of your library addresses
The text was updated successfully, but these errors were encountered: