Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

36
  • 16
    @Bargitta No, that's false. They'll do their work in parallel. Feel free to run it and see for yourself. Commented Oct 11, 2016 at 13:00
  • 14
    People keep asking the same question after years... I feel it is important to stress again that a task "starts on create" in the body of the answer: maybe they don't bother reading comments Commented May 17, 2017 at 7:24
  • 20
    @StephenYork Adding Task.WhenAll changes literally nothing about the behavior of the program, in any observable way. It is a purely redundant method call. You're welcome to add it, if you like to, as an aesthetic choice, but it does not change what the code does. The execution time of the code will be identical with or without that method call (well, technically there'll be a really small overhead for calling WhenAll, but this should be negligible), only making that version slightly longer to run than this version. Commented Oct 25, 2017 at 21:22
  • 9
    @StephenYork Your example runs the operations sequentially for two reasons. Your asynchronous methods aren't actually asynchronous, they're synchronous. The fact that you have synchronous methods that always return already completed tasks prevents them from running concurrently. Next, you don't actually do what is shown in this answer of starting all three asynchronous methods, and then awaiting the three tasks in turn. Your example doesn't call each method until the previous has finished, thus explicitly preventing one from being started until the previous has finished, unlike this code. Commented Oct 26, 2017 at 13:18
  • 18
    @MarcvanNieuwenhuijzen That's demonstrably not true, as has been discussed in the comments here, and on other answers. Adding WhenAll is a purely aesthetic change. The only observable difference in behavior is whether you wait for later tasks to finish if an earlier task faults, which there typically isn't a need to do. If you don't believe the numerous explanations for why your statement isn't true, you can simply run the code for yourself and see that it's not true. Commented Aug 1, 2018 at 13:58