本文介绍了如何发送多GET请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果责任很长,项目发送没有响应几秒钟,如果我设置代理,需要很长时间没有响应
此代码使用太多cpu,所以还有另一种发送多GET数据包的方法吗?
if respons be long , project send not responding for few second, also if i set proxy , take long not responding
this code use too many cpu, so is there another way to send multi GET packet ?
private void button7_Click(object sender, EventArgs e)
{
for (int I = 1; I < 7; I++)
{
text1.Text = text1.Text + HttpPost(URI,Parameters , Proxy[I]);
}
}
//////////////////////////////////////////////////////////////////////////////////////
public static string HttpPost(string URI, string Parameters, string PROXY)
string ResP = "";
WebProxy Prxy = new WebProxy(PROXY, true) ;
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
req.Proxy = PROXY;
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
ResP = sr.ReadToEnd().Trim();
resp.Close();
return ResP;
}
推荐答案
这篇关于如何发送多GET请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!