We had a test case which had earlier below snippet written but the test case was failing due to race condition.
Task.WaitAll(result1, result2);
But when it changed to below it started working fine.
await result1; await result2;
Note: also we marked Test case as Async too but I don't think it makes any difference since I checked all test run async alphabetically anyway by Microsoft Unit Test framework.
Task.WaitAll(result1, result2);is Blocking Call. it means that your current thread is blocked until your task is Done.awaitis a non-blocking call: it means that your current Thread will not blocked.https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/await
multiple awaits vs Task.WaitAll - equivalent?