Reputation: 120
Ok, I've been searching for all day to this problem. I have a loop, in which I load webpages and parse them.
The problem is that Application.DoEvents and while cycle reset every variable and counter Thread.Sleep() affects the thread where web page is loaded And so does AutoResetEvent.WaitOne
Here's my code
private void button1_Click_1(object sender, EventArgs e)
{
//some code...
for (int i = 1; i < div.Children.Count; i++)
{
webview.Navigate(addr);
//wait until page is loaded
html_code.Text += "OK!"; //do further actions
}
}
You notice I have a for
cycle, so all of methods listed above do not work. I ask you to help me to solve my problem
UPDATE: I've found a solution. It's described here https://stackoverflow.com/a/4271581/1894634
Upvotes: 2
Views: 314
Reputation: 13043
If you need only html responce, it's better to use WebClient.DownloadString
or WebClient.DownloadStringAsync
method
WebClient client = new WebClient ();
//client.Credentials = new NetworkCredential(username, password);
string html_code = client.DownloadString (addr);
Upvotes: 2