【发布时间】:2012-07-05 07:20:31
【问题描述】:
我有这样的方法
private bool VerbMethod(string httpVerb, string methodName, string url, string command, string guid, out HttpWebResponse response)
我是这样用的
HttpWebResponse response;
if (VerbMethod("POST", "TheMethod", "http://theurl.com", "parameter1=a", theGuid, out response))
{
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
string responseString = sr.ReadToEnd();
}
它返回一个布尔值来指定方法是否运行良好,并在一个out参数中设置响应以获取数据。
我有时会超时,然后后续请求也会超时。我看到了这个 WebRequest.GetResponse locks up?
它推荐using 关键字。问题是,使用上述方法签名我不知道该怎么做。
- 我应该在 finally 中手动调用 dispose 吗?
- 有没有办法仍然使用
using和out参数? - 重写方法,使其不暴露
HttpWebResponse?
【问题讨论】:
标签: c# timeout using httpwebresponse out