I have a web page with multiple tabs. One tab contains a lot of data, and for this reason I need to write an async method, because in synchronous way it takes long loading the tab.
I tried to do, but it seems that it behaves synchronous.
This is my controller method:
public async Task<ActionResult> ProductDetails(int id, string selected, string category)
{
..........
///Code
#region Matching Vehicles tab
List<MatchingVehiclesVM> matchingVehicles = new List<MatchingVehiclesVM>();
productVM.ProductMatchingVehicles = await GetMatchingVehiclesAsync(product.Id);
#endregion
}
public async Task<List<MatchingVehiclesVM>> GetMatchingVehiclesAsync(int id)
{
return await Task.Run(() => GetMatchingVehicles(id));
}
private List<MatchingVehiclesVM> GetMatchingVehicles(int id)
{
//contains the code that returns from database the needed list
}
Can you advise what I had missed here to make it to work in async way? Thanks!
but it seems that it behaves synchronous.why do you think so?