I have Class1.cs and MainWindow.xaml and .cs.
Class1.cs looks like this
    var login = htmlDoc.getElementById("login") as HTMLFormElement;
                if (login != null)
                {
                    login.submit();
                }
            var registerForm = htmlDoc.getElementById("register") as HTMLFormElement;
            if (registerForm != null)
            {
                registerForm.submit();
            }
In my MainWindow.cs i have a webBrowser control that loads page and waits for user. On user input i fill some input boxes and submit form. That's login.submit(). After that's executed my registerForm is always null since webBrowser control has no time to actually change content. How can i delay execution of code after login.submit and wait for page to finish loading?