日期:2014-05-17 浏览次数:21107 次
public string GetWebPageResponse(string uriArg)
{
System.IO.Stream responseStream = System.Net.WebRequest.Create(uriArg).GetResponse().GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(responseStream);
return reader.ReadToEnd();
}
private void button1_Click(object sender, EventArgs e)
{
new System.Threading.Thread(delegate()
{
string strHtml = GetWebPageResponse("http://www.baidu.com/");
// 后台执行部分
this.Invoke((EventHandler)delegate
{
richTextBox1.Text = strHtml;
// 操作UI部分
});
}).Start();
}