Closed
Description
Description
Run this code:
await Task.WhenAny(new List<Task>())
And it will hang your process.
This is a highly undesirable default behavior. It is not obvious this will hang and there is no easy way to detect that this was the cause.
Other information
I recommend one of the following adjustments:
If using Task.WhenAny()
on an empty list/enumerable/array:
A) Throw a Sequence contains no elements
exception.
OR
B) Immediately return Task.CompletedTask or Task.FromResult(default(T))
I am OK with either, but I think that A is the best option.