I need to navigate to a certain url using a webBrowser1 in my form and performing certain operations:
webBrowser1.Url = new Uri(@url);
webBrowser1.Navigate(new Uri(@url));
var state = webBrowser1.ReadyState;
        HtmlElementCollection links = webBrowser1.Document.GetElementsByTagName("a");
        foreach (HtmlElement link in links)
        {
            if (link.InnerText != null)
            {
                if (link.InnerText.Equals("Log in"))
                {
                    link.InvokeMember("Click");
                    webBrowser1.Document.GetElementById("templateLoginPopupUsername").InnerText = username;
                    HtmlElementCollection input = webBrowser1.Document.GetElementsByTagName("input");
                    foreach (HtmlElement item in webBrowser1.Document.All)
                    {
                        if (item.Name == "password")
                        {
                            item.InnerText = password;
                            break;
                        }
                    }
                    break;
                }
            }
        }
the page only loads when the code is entirely done executing, so I can't perform any operations on it. Is there any way to force the browser to load?
 
     
    