给定以下样例代码:
var count = 0;
while (count < 5)
{
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
using (var response = await StaticHttpClient.Client.SendAsync(request))
{
if (!response.IsSuccessStatusCode)
{
switch ((int)response.StatusCode)
{
case 500:
case 504:
continue;
}
}
else
{ ... }
}
count++;
}
这个方法中的IDisposable对象是否会泄漏内存?还是Dispose方法会被正确调用?(switch语句中有很多情况被省略,我不担心效率问题。)