Consider the following C# code:
var task1 = GetSomethingAsync();
var task2 = GetSomethingElseAsync();
await Task.WhenAll(task1, task2); //is this required?
var something = await task1;
var somethingElse = await task2;
Does Task.WhenAll()
make any difference for speed of execution (NOT for how any errors will be thrown)? If not, any reasons why I should have it anyway?
Update:
As a few people rightly pointed out, I should be using WhenAll() rather than WaitAll() - I've updated the question. But I'm still not clear on the answer - is there a reason to have WhenAll()? One of the answers here Why should I prefer single 'await Task.WhenAll' over multiple awaits? talks about fast-track async methods. If my async methods are fast-track, would it make a difference? I'm mainly concerned with the execution time, i.e. is it possible that without WhenAll() my two calls will execute sequentially. But also would be good to know if there are any other reasons to use WhenAll().