Skip to content

Give ToList preference for WhenAny #34606

Open
@DickBaker

Description

@DickBaker

Docs suggest using LINQ extension method ToArray() to initiate execution. Whilst this is true and may be the right style for WhenAll() coding, I favour use of ToList() instead as this is more appropriate for the WhenAny() style [handy to handle completions as they arise] as often you have to .Remove() that completed Task from the in-progress list (s.t. all work is only complete when that list is empty). Would be good to explain & contrast imho. Thanks.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions