So I have a method that chains tasks together to do work
var tasks = new List<Task>();
tasks.Add(DoWorkAsync(1));
tasks.Add(DoWorkAsync(2));
tasks.Add(DoWorkAsync(3));
tasks.Add(DoWorkAsync(4));
tasks.Add(DoWorkAsync(5));
tasks.Add(DoWorkAsync(6));
await Task.WhenAll(tasks.ToArray());
To get better performance/responsiveness out of this method I was looking at using ConfigureAwait(false)
The above method does not have any need to run on the same synchronisation context as the calling thread.
what is the correct way to use ConfigueAwait(false)
when chaining Tasks
and do I need to use ConfigureAwait
for each individual task and/or do i need to use it on Task.WhenAll
As an extra question...
Does ConfigureAwait
actually do anything (or improve performance/responsiveness) if there is no code that runs after the await?