I have the following scenario here. How can make some parallel processing while the DB call runs asynchronously.
/// <summary>
/// Async query EF6.0
/// </summary>
/// <returns></returns>
public async Task<ActionResult> AsyncQuery()
{
var result = await GetAsyncDepartments();
Debug.WriteLine("Do some stuff here");
return View("Index");
}
private async Task<List<Department>> GetAsyncDepartments()
{
var depts = new List<Department>();
using (var newContext = new DemoEntities())
{
depts = await newContext.Departments.ToListAsync();
}
Debug.WriteLine("Got departments");
return depts;
}
It actually waits for the Task to be completed and then goes to the statement "Do some stuff here".
How can call the GetAsyncDepartments() asynchronously and do some extra stuff till the call returns. Thank you.