C# WebBrowser readystate

Status
Not open for further replies.

dogved

Registered
Original poster
Joined
Aug 10, 2011
Posts
5
Reaction score
0
Points
0
Hi I found this piece of coding in another thread, unfortunately it was closed. My question is to use the code below do I need to call WaitBrowserLoading() after my webBrowser1.Navigate(new Uri(Url)); code or do I just need to simply add it to my .cs class and it'll pick up?

Code:
void WaitBrowserLoading()
        {
while (webBrowser1.IsBusy)
                Application.DoEvents();
            for (int i = 0; i < 500; i++)
                if (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(10);
                }
                else
                    break;
            Application.DoEvents();
        }
 

Flip

Old School
old school
member
Joined
Jul 23, 2009
Posts
263
Reaction score
69
Points
108
You'd just want to do
Code:
WaitBrowserLoading();

after a webBrowser action where you'd like it to wait (navigating or something like clicking a submit button).
 

dogved

Registered
Original poster
Joined
Aug 10, 2011
Posts
5
Reaction score
0
Points
0
You'd just want to do
Code:
WaitBrowserLoading();

after a webBrowser action where you'd like it to wait (navigating or something like clicking a submit button).

thanks that worked perfectly
 
Status
Not open for further replies.