Task.WhenAll result ordering
I understand from here that the task execution order for Task.Whenall
is not deterministic but I cannot find any information about result order.
Will the results collection contain the results in the order in which the tasks where ordered in the input or the results can be in any order?
From the tests that I did, it seems to keep the order but I need a confirmation.
From MSDN:
Task.WhenAll<TResult>(IEnumerable<Task<TResult>>)
This is the only overload of the four which contains this statement:
If none of the tasks faulted and none of the tasks were canceled, the resulting task will end in the RanToCompletion state. The Result of the returned task will be set to an array containing all of the results of the supplied tasks in the same order as they were provided (e.g. if the input tasks array contained t1, t2, t3, the output task's Result will return an TResult[] where arr[0] == t1.Result, arr1 == t2.Result, and arr[2] == t3.Result).