What if I don't use the list? like this:
Task.WhenAll() is used to await a list of tasks. If you do not have a list of tasks then you don't need await Task.WhenAll(). I can't read your mind. I have no idea what you're trying to do. One of your posts has a ContinueWith which is also implemented incorrectly. Are you trying to implement ContinueWith and need an example?
Console.WriteLine("Async Example");
Console.WriteLine();
Task continuationTask = WidgetSizeReturnColorAsync(10).ContinueWith(c => Console.WriteLine($"The widget color is set to {c.Result}"));
Console.WriteLine("Doing some work while Widgets tasks are executing");
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
await continuationTask;
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
Console.WriteLine("The Widget tasks are complete.");
static async Task<string> WidgetSizeReturnColorAsync(int size)
{
await Task.Delay(5000);
Console.WriteLine($"The widget size is set to {size}");
return "Red";
}
It is much easier to help of you tell us what you are trying to do rather than telling us what you are NOT trying to do.
will it do the same?
No. If you read the openly published Task.WhenAll() reference documentation you would find the method requires at least a collection of tasks to await. If you don't pass the task collection then how does the method know what tasks to await?
Secondly, I provided sample code where you can test what happens if no parameters are passed to Task.WhenAll().
I'm not sure how to help you. It seems like you are not making an effort to learn the asycn/await pattern and you are ignoring my advice.