What’s the best way to code in a wait for the browser to finish process before continuing? I tried this code below and the process is not waiting till its complete before processing the next link.
void WaitBrowserLoading()
{
while (webBrowser1.IsBusy)
Application.DoEvents();
for (int i = 0; i < 500; i++)
if (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
lblStoreID.Text = "";
//System.Threading.Thread.Sleep(5);
}
else
break;
Application.DoEvents();
}
Do the
NavigatedorDocumentCompletedevents do what you want? I suspect the latter is more appropriate for you:Basically you’d disable all the controls (or whatever you want to “stop”) before navigating, then re-enable them when the event fires.