views:

290

answers:

3

is there a way to know that the WebBrowser control has finished loading the page?
currently i am using WebBrowser.ReadyState == WebBrowserReadyState.Complete.
but this indicates that the webpage content is downloaded but sometimes the flash is not loaded yet.

+3  A: 

A Flash file loading doesn't report its progress on that back to the browser so unfortunately you can't catch that.

Joey
Yup. Same problem with Javascript.
Hans Passant
A: 

The WebBrowser control has a DocumentCompleted event which you can catch and react on. I don't know if that includes the Flash content loading - the docs aren't very clear on that....

webBrowser1.DocumentCompleted += 
     new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);

private void webBrowser1_DocumentCompleted(object sender, 
                                     WebBrowserDocumentCompletedEventArgs e)
{
   // do whatever you need to do when the document is completely loaded here
}
marc_s
no that dont include flash :(
Karim
but even so, it's easier and more efficient than constantly polling for `WebBrowser.ReadyState == WebBrowserReadyState.Complete.`
marc_s
yeah but i am running several Webbrowsers on several worker threads, so the code got messy when i tried to implement events. so i left it like that. sure the cpu is @ 100% all the time but i need the task to get done. :)
Karim
@KArim: ah, okay - good point.
marc_s
A: 

well the best thing i have found is to use a timer to wait for a specifique time like 30 seconds and then the page should be loaded.
not perfect but the best i have thought of.

Karim