如何在GetResponseStream完成之前产生?

时间:2014-05-10 22:57:00

标签: c# multithreading httpwebrequest

我使用此代码(如下)阅读网页回复,但是,我收到的回复不完整。如果我System.Threading.Thread.Sleep(5000);,在我运行GetResponseStream();之后,我会得到完整的回复。

HttpWebRequest http = (HttpWebRequest)HttpWebRequest.Create(url))
HttpWebResponse response = (HttpWebResponse) http.GetResponse();
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
    string response = sr.ReadToEnd();
}

在完成之前我该如何屈服?

0 个答案:

没有答案