using (var client = new WebClient())
{
html = client.DownloadString(some_string);
//do something
html = client.DownloadString(some_string1);
//do something
html = client.DownloadString(some_string2);
//do something
html = client.DownloadString(some_string3);
//do something
etc
}
webclient does not allow itself enough time to download the entire source of the webpage. how do i force it to wait until it finishes the donwload?
DownloadString is a blocking call, so there is no need to do anything. It will continue to download until the string is received.
The problem probably lies in the fact that you shouldn’t be using DownloadString. What are you trying to retrieve? Do you end up with half of your expected string?
You should probably use it as the MSDN article shows:
The source is here: http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx