0

I've a code using multiple functions that returns Task. I am trying to use Task.WhenAll to optimize the time and code, but I need to get the return from the tasks. Any tips to deal with it?

This is how my code looks like:

var task1 = TaskFcuntionOne();
var task3 = TaskFcuntiontwo();
var task3 = TaskFcuntionThree();

await Task.WhenAll(task1, task2, task3);

I would like to get a return from the WhenAll, is this even possible?

Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
Lincoln Teixeira
  • 145
  • 2
  • 10

1 Answers1

2

Once you have successfully awaited Task.WhenAll, you know that the tasks are completed, so you can use task1.Result, task2.Result, etc. to get the individual task results.

Mark Sowul
  • 10,244
  • 1
  • 45
  • 51