A colleague of mine has refactored our controller methods so that all of our IO operations, including the synchronous ones, are encapsulated in separate tasks and then all those tasks are executed in parallel via Task.WhenAll. I can definitely understand the idea: we use more threads but all of our IO operations (and we can have quite a few) are executed with the speed of the slowest one, but I'm still unsure whether it is a correct path to go. Is it a valid approach or I'm missing something? Is the cost of using more threads going to be noticeable in a typical ASP.Net website application?
Here is some sample code
public async Task<ActionResult> Foo() {
var dataATask = _dataARepository.GetDataAsync();
var dataBTask = Task.Run(_dataBRepository.GetData());
await Task.WhenAll(dataATask, dataBTask);
var viewModel = new ViewModel(dataATask.Result, dataBTask.Result);
return View(viewModel);
}