Good day,
Parallel execution can be achieved through multiple ways. From strictly manual "multithreading" to using various "helpers" created by Microsoft. One of those helpers is the Parallel class.
One of my colleagues is insisting that Parallel.ForEach (or Parallel class overall) is "old" and shouldn't be used. Instead, he says, one should use async operations. In other words you should use Task.WhenAll() instead of ParallelForEach() .
When asked why not use ParallelForEach(), when this is exactly what was needed - multiple expensive operations executed in parallel, he replied that ParallelForEach is old and that Microsoft recommends using async/await wherever possible.
I searched all over MSDN and Stackoverflow and everywhere I could but I couldn't find anything pointing at the necessity of using async/await instead of .Parallel. While you often can achieve similar results by interchanging these tools it doesn't mean that Parallel.ForEach is obsolete. Or does it?
Anyone has a link to some "best practices" or "recommendations" by a reputable body (MSDN?) that would say that Parallel.ForEach is being phased out and one needs to stick with creating, running and awaiting tasks?
Please do not post answers related to Parallel VS Async for this is not the question. The question is: Since you can make tasks run in parallel using async/await WhenAll (WaitAll etc), does it make Parallel class obsolete, old, or not fashionable in .NET 4.5 onward?
Aucun commentaire:
Enregistrer un commentaire