by reading the following guide https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/ I was trying to create three tasks that should run async, concurrently, but they actually run synchrously. I'm wondering where I'm wrong
Task<double?[]> rainfallGridValuesTask = Rainfall.ValuesAsync(rainfallGridValuesRepo.GetAll()); //it takes 5s
Task<double?[]> rainfallAvgValuesTask = Rainfall.AveragesAsync(rainfallAvgGridValuesRepo.GetAll()); //it takes 5s
Task<double?[][]> rainfallAnomaliesTask = Rainfall.AnomaliesAsync(rainfallGridValuesRepo.GetAll()); //it takes 5s
where the methods are like the following:
public static async Task<double?[]> Values(IQueryable<RainfallGridValue> rainfallGridValues)
{
double?[] outputValues = new double?[108];
System.Threading.Thread.Sleep(5000); //Simulate the time taken by the method
return outputValues;
}
Then I try to get the value returned by the task in this way:
rainfallValueChart.Data = await rainfallGridValuesTask;
rainfallAverageChart.Data = await rainfallAvgValuesTask ;
rainfallAnomalyChart.Data = await rainfallAnomaliesTask ;
But when I run this code, it waits for 5s on each of the three Async methods, so what's wrong and how can I run them concurrently and proceed when all tasks have been completed?