When passing multiple completed tasks to Task.WhenAny does Task.WhenAny give a preference to which task completed Task will be returned?
When you want to know the exact behavior, you can often check the reference source. For instance, WhenAny
can be found here.
When looking through the source, note that the returned task is not one of your tasks, but an internally-created task (either a CompleteOnInvokePromise
instance or continuation of it), whose Result
will be one of your tasks. In the case where you are passing completed tasks into WhenAny
, the Result
is immediately set to the first completed task it encounters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With