Hey!
I use the following piece of code(Not mine!) to wait for the web browser to fully load the page.
It works perfect but its not good for the memory because this method is used allot.
Any optimization tips?
Code:private void waitTillLoad(WebBrowser webbrowser) { WebBrowserReadyState loadStatus; //wait till beginning of loading next page int waittime = 100000; int counter = 0; while (true) { loadStatus = webbrowser.ReadyState; Application.DoEvents(); if ((counter > waittime) || (loadStatus == WebBrowserReadyState.Uninitialized) || (loadStatus == WebBrowserReadyState.Loading) || (loadStatus == WebBrowserReadyState.Interactive)) { break; } counter++; } //wait till the page get loaded. counter = 0; while (true) { loadStatus = webbrowser.ReadyState; Application.DoEvents(); if (loadStatus == WebBrowserReadyState.Complete) { break; } counter++; } }




Reply With Quote