2
Answers

Lock a WebBrowser object until DocumentComplete

Ask a question
Joakim Astrom

Joakim Astrom

14y
8.1k
1

Hello everyone.
I have a problem when I use the WebBrowser object for navigating to multiple urls, one after the other. I have a list of urls. And for each url I want to navigate to this url, when DocumentCompleted event occurs, parse the information, and then go on to the next url in my list.
However, I need to lock the WebBrowser object in my foreach loop until a DocumentComplete event takes place, and then move on so it does not interrupt the download before it's completed. How can I do this?
Sort of like this:
foreach (string url in myUrlList)
{
      if
(!this.Browser.IsBusy)
      {
            this.Browser.Navigate(artNo);
            this.Browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DocumentCompleted);
      }
}
 
..but this example doesn't work. Just to give an idea of my problem.
Thanks in advance for any suggestions!

Answers (2)