I have questions regarding the execution order of async jobs.
I will ask my question with example because it is easier to be understandable.
It is an official example from https://msdn.microsoft.com/en-us/library/mt674882.aspx with some twist.
async Task<int> AccessTheWebAsync()
{
HttpClient client = new HttpClient();
//async operation:
Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");
// You can do work here that doesn't rely on the string from GetStringAsync.
DoWork1();
// The await operator suspends AccessTheWebAsync.
string urlContents = await getStringTask;
DoWork2();
return urlContents.Length;
}
Can I say DoWork2
is a callback of client.GetStringAsync
?
If so, DoWork2
is not immediately executed following the completion of client.GetStringAsync
IF DoWork1
runs longer time than client.GetStringAsync
.
Am I right here?