给定以下示例代码:
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 方法?(开关中缺少很多案例,我不关心那里的效率)。