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*

8
  • 1
    @YuryShcherbakov Task.WhenAll() isn't returning a tuple. One is being constructed from the Result properties of the provided tasks after the task returned by Task.WhenAll() completes. Commented Aug 18, 2017 at 23:20
  • 2
    I'd suggest replacing the .Result calls as per Stephen's reasoning to avoid other people perpetuating the bad practice by copying your example. Commented Oct 2, 2018 at 20:28
  • 1
    I wonder why this method isn't this part of the framework? It seems so useful. Did they run out of time and have to stop at a single return type? Commented Sep 16, 2019 at 7:52
  • 2
    @nrofis That's false. Both tasks are created and therefore started before either is awaited. It's equivalent to Servy's answer. Commented Sep 19, 2021 at 21:09
  • 1
    In case task2 will fail with exception, than task 1 will fail with exception, you will never catch exception from task2, it will be unobserved. In case you are logging errors using try catch unobserved exception will never appear in your logs. You can add call to await Task.WhenAll(task1, task2) before return to address this. Commented Mar 9, 2023 at 13:04