Write FAST C# Code - Task.WhenAll vs Parallel.ForEachAsync in DotNet
July 20, 2023
• 5,825 views
c# tutorialdotnetdotnet coredotnet core tutorialdotnet core c#c# dotnet corec# programmingcsharpC# optimizationC# code optimizationc# speedbenchmarkbenchmarksC# benchmarkshow to benchmark C#benchmarkdotnetbenchmarkdotnet how to usebenchmarkdotnet tutorialbenchmarkdotnet setuphow to use benchmarkdotnetbenchmark c# codetask whenall in c#parallel foreach async c#parallel foreachparallel foreach c#c# parallel foreachc# parallelc#
You've found yourself trying to optimize your algorithm and the only way you can see to squeeze out more performance is to run things in parallel. We can use a parallel foreach or we can look at task when all in C#! So, do you go with Task.WhenAll or do you leverage Parallel.ForEachAsync? Let's use BenchmarkDotNet and have the benchmarks speak for themselves.
For more videos on programming with detailed examples, check this out:
https://www.youtube.com/playlist?list=PLzATctVhnsghN6XlmOvRzwh4JSp...
