Wait Function in VB .NET??
Posted on 2006-10-28
Anyone know of a wait function I can use in vb .NET to pause the program while I wait for my (form based) web browser to load (i.e. to reach readystate_complete)?
I tried this:
- create a form class (with a webbrowser on it)
- create a bool variable in this class called load_complete (this boolean gets set to true for each instance of the class when that instance's WebBrowser document_complete event gets fired)
- create a class called DoStuff which inherits the form class
- within a sub in the DoStuff class, create a form object and navigate its axWebBrowser1 to some url
- send this sub into a loop waiting for the complete_load property of the form object to be set to true.........Do While form.complete_load <> true Sleep(100) Loop
- the idea was that when document_complete gets fired for the instance of the form, that instance's load_complete property would get set to true and the DoStuff sub's loop would be exited leaving that sub to move on with its life
There is a problem with this approach in that sleep(100) seems to kill all processing in the program which means the document_complete event of the form classes browser doesnt get fired (I dont even think the webbrowser makes it to the page, it just hangs).
I need something that pauses the program but will not stop document_complete getting fired when the webbrowser has succesfully loaded the page.