Assume the following fictitious (and useless) methods:
public async Task SomethingAsync()
{
await SomeAsyncOperation();
}
public async Task Execute(int numOfTimes)
{
var tasks = new List<Task>();
for (var i = 0; i < numOfTimes; i++)
{
// how does this...
var task = Task.Run(async () => await SomethingAsync());
// differ to the line below? (i.e. no async/await in Task.Run)
// var task = Task.Run(() => SomethingAsync());
tasks.Add(task);
}
await Task.WhenAll(tasks);
}
public async Task Test()
{
await Execute(10);
}
How does the presence or absence async/await
keywords within Task.Run()
affect the tasks in question?
I found a similar question on SO, which however .Result
ed the task, something which I am not doing.