Hi, I have a function that passes the URL, receives the parameters for a PHP file on a webserver and waits for a response from the file (
Usually 10- It takes 20 seconds) I want to put it inside a loop because I have to send these 5 requests to 5 different php files at a time, but when I want to add it to the loop, the function waits for the loop. When the first file reaction will return now to the next.
public string HttpGet (string URI, string parameter) {HttpWebRequest request = (HttpWebRequest) WebRequest.Create (UI + parameter); HttpWebResponse response = (HttpWebResponse) request.GetResponse (); StrimmerdreamRestStream = New Streamerder (Reaction Gateresonsstream ()); Return Restream Readout () Trim (); } Private Zero SendCommand () {for (int i = 0; i & lt; = 4; i ++) {AddRTB (HttpGet (url, paramater)); }}
Is there any way I can send all 5 requests once without waiting for the last time to finish? (I was thinking about threading it but never touched me before, I do not know where to start from.)
GetResponse ()
, you can use a non-blocking call that takes a callback that is then the WebResponse
can handle the object when the return is given at the end The example given in the link will give you a good idea that all the responses How to wait for the main thread to return.
Comments
Post a Comment