SwiftHands
SwiftHands

Reputation: 253

Task.WaitAll() - no parameters

Using System.Threading.Tasks.Task.WaitAll() I could see the available parameters I should be using with this method

Can be seen here but when writing in visual studio, I was able to call the method with no parameters at all:

Task.WaitAll();

and it didn't show up as a syntax error in the IDE (for missing parameters), can you please explain why is this possible with this specific method?

Upvotes: 3

Views: 1337

Answers (2)

knittl
knittl

Reputation: 265807

The method is overloaded. One overload is of the form:

public static void WaitAll(
    params Task[] tasks
)

The params parameter can take zero or more parameters.

Upvotes: 3

Henk Holterman
Henk Holterman

Reputation: 273691

The full definition of this method is

public static void WaitAll(params Task[] tasks)

The word params indicates that the method accepts a variable number of arguments. 0 arguments is also explicitly allowed.

Needless to say the method has no effect when called this way.

Upvotes: 13

Related Questions