Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ?
C#
 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;
  }
Posted
Comments
Suvabrata Roy 17-Jul-14 0:21am    
You are not sending multiple request at same time rather you send sequential request.

Which framework you are using ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900