c# - Can you "Queue" webRequest to the background to speed up your program? -


the slowest part of code these lines right here:

        string responsestring;         var webrequest = webrequest.create(url);         using (var response = webrequest.getresponse())         using (var sr = new streamreader(response.getresponsestream()))         {             responsestring = sr.readtoend();         }         return responsestring; 

is there way "queue up" multiple webrequest , have them download in background while code parses html between page requests? there name/method can google? links or code appreciated! thanks!

*edit: full gethtml() code added

you can use async methods, unblock ui , handle requests there.

but posted line of code should nothing. request server occurs when calling response. with:

var respone = webrequest.getresponse(); 

just use the, unblock ui , handle after async progresss ist done.

var response = webrequest.getresponseasync(); // or beginresponse() ... endresponse(); 

you can read following further information: http://msdn.microsoft.com/en-us/library/86wf6409(v=vs.110).aspx


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -