Javon Zhang

Javon Zhang

  • NA
  • 1
  • 9.7k

How to improve HttpWebRequest's performance ?

Mar 19 2013 3:36 AM
thks for your comein, my question is that:
I use HttpWebRequest to get one URL content with "GET" Method,
and many guys want to get it like me,
I try to get the message first while the URL content change,
but I always slower than the others.
I want to know how to improve HttpWebRequest's performance effectively.

my general code :

int interval = 10;

Thread = null;
void Query(string url)
{
while(true){
        thread = new Thread(new ThreadStart(()=>{
        try{
        HttpWebRequest request = (HttpWebRequest)Webrequet.creaete(url);
        ....
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        StreamReader reader = new StreamReader(response....Stream());
        this.ExecuteHtmlHanlder(reader.ReadToEnd());
        }catch{...}
        }));
        thread.IsBackGround = true;
        thread.Start();
        Thread.Sleep(interval);
}
}

Answers (1)