我有一些类似的代码,这段代码被大量使用:
using (HttpWebResponse r = _GetHttpWebResponse(uri, body, method, contentType, headers)) {
/* do something with the response */
/* call r.Close() explicitly? */
}
该代码今天运行良好,但与服务器的连接保持打开了相当长的一段时间。(使用 TCPView 检查)
显式调用该Close()
方法有好处吗?是推荐还是不推荐,为什么?