I have a situation where I make an async call to the returned method and IDisposable instance. For example:
HttpResponseMessage response = await httpClient.GetAsync(new Uri("http://www.google.com"));
Now, before async was on the scene, when working with an IDisposable instance, this call and the code that used the "response" variable would be wrapped in a using statement.
My question is, is this approach correct when the async keyword is selected in the mix? Although the code compiles, will the using statement continue to be executed in both examples below?
Example 1
using(HttpResponseMessage response = await httpClient.GetAsync(new Uri("http://www.google.com"))) {
Example 2
using(HttpResponseMessage response = await httpClient.GetAsync(new Uri("http://www.google.com"))) { await this.responseLogger.LogResponseAsync(response); return true; }
c # asynchronous using-statement
swingdoctor May 15 '13 at 13:36 2013-05-15 13:36
source share