When I read the MSDN documentation on Task.WaitAll(params Task[] tasks)
it says it throws an ArgumentException when:
The tasks argument contains a null element.
-or-
The tasks argument is an empty array.
But when I call Task.WaitAll(new Task[0]);
it passes on without any exception.
Am I misunderstanding the documentation, or is this just an error (or outdated info)?
I understand Task.WhenAll(new Task[0])
does the same, except returning a task of course. This feature was sometimes used to get a completed task, before Task.CompletedTask
was introduced in .NET 4.6.
I am actually glad that Task.WaitAll()
seems to behave this way, so I don't have to treat an empty array as a special case, but I still want to make sure that I understood it right.
I am running my application on 4.5.2 by the way. But I just made a new solution targeted to 4.6.1 and it behaves the same way.