user34537
user34537

Reputation:

How to check if webbrowser control is busy/in use?

I am loading a page in a webbrowser control. How can i check when its completely done? i know about DocumentCompleted, but one page may call it 5 or many more times. How do i check when its completely done?

Upvotes: 0

Views: 1988

Answers (2)

HappyNomad
HappyNomad

Reputation: 4548

Your DocumentCompleted handler gets called for the main document, as well for each frame within that document. The number of calls depends on the particular webpage you've opened.

Using the ReadyState property as shahkalpesh suggested sounds reasonable, although I know another way that will work. Presuming your event handler has this signature:

  void OnDocumentComplete( object pDisp, ref object url )

and you have a reference to the main document, then you can check

  pDisp == mainDoc

to see if the call is originating from the main document. In my experience you should also cast pDisp to IWebBrowser2, then cast its Document property to IHTMLDocument2, then check that its body property is non-null. If so, then the document has been completely loaded.

Upvotes: 1

shahkalpesh
shahkalpesh

Reputation: 33474

Does the ReadyState property help?
There is also a boolean property Busy. I guess, that should help too.

Upvotes: 2

Related Questions