Skip to content

Task.WaitAll does not throw on empty array #2605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

DAXaholic
Copy link
Contributor

According to the current documentation for Task.WaitAll

ArgumentException
The tasks argument contains a null element.

-or-

The tasks argument is an empty array.

the following should throw and catch an exception and consequently write ArgumentException thrown to the console.

using System;
using System.Threading.Tasks;

static void Main(string[] args)
{
    try
    {
        Task.WaitAll();
        Console.WriteLine("Should not reach this point");
    }
    catch (ArgumentException)
    {
        Console.WriteLine("ArgumentException thrown");
    }
}

However - just like Task.WaitAny - waiting on an empty array of tasks does not throw an exception.

Therefore, this commit will remove the wrong statements about throwing an exception on empty arrays for Task.WaitAll.

@dnfclas
Copy link

dnfclas commented Jun 16, 2019

CLA assistant check
All CLA requirements met.

@rpetrusha rpetrusha added this to the June 2019 milestone Jun 17, 2019
@rpetrusha rpetrusha added the ✨ 1st-time dotnet-api-docs contributor! Indicates PRs from new contributors to the dotnet-api-docs repository label Jun 17, 2019
Copy link

@rpetrusha rpetrusha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @DAXaholic, for contributing to the dotnet/dotnet-api-docs repo and correcting the erroneous exception information. We'll merge your PR now. Your changes should be live on docs.microsoft.com in the next day or two.

@rpetrusha rpetrusha merged commit 73521ce into dotnet:master Jun 17, 2019
@DAXaholic DAXaholic deleted the task-waitall-no-throw-empty-array branch June 17, 2019 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ 1st-time dotnet-api-docs contributor! Indicates PRs from new contributors to the dotnet-api-docs repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants