Reputation: 13553
Lets say that I use HttpWebRequest
to call a web-service written in python and that service returns a XML file. Lets assume that it takes 10 seconds to download the data.
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
if(allDate100%Transfered)
MsgBox.show("u can now CUT your cable. All data is there!!!");
Are there any property to check if everything have been transferred?
Because I want to proceed and for example read the received data into a string, but only when all data have been downloaded successfully.
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
String xml = reader.ReadToEnd();
Do I get any message or sign from the webservice, which tells me that all data is really there and I do not need the connection anymore?
Edit: The problem is stil there. I get different answers and they contradict each other.
Upvotes: 0
Views: 238
Reputation: 101130
request.GetResponse()
is synchronous which means that it doesn't return until all data have been downloaded.
The documentation of request.GetResponse()
states that WebException
is thrown if:
Which means that everything went OK if no exception was thrown.
Upvotes: 2