If you store the results in a
List<Task>
, the methods will be invoked once, and you will be able to retrieve the results from the list.
If you want to invoke the methods multiple times on demand, store them in a
List<Func<Task>>
:
var listOfDelegates = new List<Func<Task>>
{
instanceOfMyClass.SomeFunctionAsync
};
...
List<Task> listOfTasks = listOfDelegates.Select(fn => fn()).ToList();
await Task.WhenAll(listOfTasks);