I am trying to asynchronously complete four tasks and when they are all complete, append them to an object and return it.
Here is my code:
Task[] tasks = new Task[4];
tasks[0] = wtData.GetHFServiceData(wtTransfreeeId);
tasks[1] = wtData.GetTLServicesData(wtTransfreeeId);
tasks[2] = wtData.GetHMAServiceData(wtTransfreeeId);
tasks[3] = wtData.GetHSServiceData(wtTransfreeeId);
Task.WaitAll(tasks);
The problem is, since Task[]
has no Result method, I have to define a type like Task<MyType>[]
. But, each of the four tasks above return a different type.
How can I wait until all tasks are complete before adding them to my combined object and returning it?