I've been reading about the use of async-await
and there's one concept I'm not really sure I quite understood because most of the examples consider what happens to the execution of the calling method and not the actual async
method.
Suppose I have this piece of code
...
var r1 = await httpClient.GetAsync(url1);
var r2 = await httpClient.GetAsync(url2);
...
Will the second GET request for url2
be executed only after content of url1
has been downloaded or can it be executed also before content of url1
is downloaded?
In other words, will the following code call both URLs at the same time without waiting for the first one to finish and the "waiting" only happens at the await r1
/await r2
lines?
...
var r1 = httpClient.GetAsync(url1);
var r2 = httpClient.GetAsync(url2);
var response1 = await r1;
var response2 = await r2;
...
Lastly, can you confirm that there is a difference between these 2 pieces of code I provided?
Thanks