Navigate with C# WebBrowser control to a link and wait for full page loading


If you need to build an application that is using the functionality of the WebBrowser control and want to wait until a page is loaded (somehow simulating the synchronous loading of a page), you can use the following piece of code:

private const int sleepTimeMiliseconds = 5;

public void NavigateAndWaitForLoad(WebBrowser wb, string link, int waitTime)
    int count = 0;
    while (wb.ReadyState != WebBrowserReadyState.Complete)
        if (count > waitTime / sleepTimeMiliseconds)


%d bloggers like this: