Await tasks with multiple result types
Regularly I want to await a few tasks and get their result. Surprisingly, there is no obvious way to do that. Task.WhenAll can be helpful, as we see later, but it doesn't solve the problem.My common scenario looks like this:
var dbTasks = getDataFrom...
blog.ciechowski.net2 min read
Hey Kuba, nice article!
On
We should be able to do a Task.WhenAll on tasks with different return types.
await Task.WhenAll(taskReturnsInt, taskReturnsString); // next lines would execute only after Task.WhenAll completed // block and get result var intResult = taskReturnsInt.Result; // or asynchronously get result var stringResult = await taskReturnsString;