In the article about eliding async await, there is an example as follows:
public Task<string> GetElidingKeywordsAsync(string url)
{
using (var client = new HttpClient())
return client.GetStringAsync(url);
}
And he described the flow as follows:
With GetElidingKeywordsAsync, the code does this:
Create the HttpClient object.
Invoke GetStringAsync, which returns an incomplete task.
Disposes the HttpClient object.
Returns the task that was returned from GetStringAsync.
Why isn't the flow as follows?
Create the HttpClient object.
Disposes the HttpClient object.
Invokes the GetStringAsync, and returns the task that was returned from GetStringAsync.