I have a method which takes a int input and return Task<Dictionary<DateTime, HistPrice>>
public static async Task<Dictionary<DateTime, HistPrice>> GetPrices(int seriesId) {
...
return Dictionary<DateTime, HistPrice>;
}
Now I want to call the above method for list of values 1,2,3,4,5,6,7,8 in parallel.
List<int> seriesIdDist = new List<int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8 });
var tasks = new List<Task>();
foreach(var t in seriesIdDist) {
tasks.Add(GetPrices(t));
}
await Task.WhenAll(tasks);
Till here everything is working fine, problem is in extracting the result from the task. I tried to extract the result like
foreach(var ta in tasks) {
var res = await ta;//error in this line
}
but it says
CS0815 Cannot assign void to an implicitly-typed variable
What am I missing here ?