0

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?

azza idz
  • 623
  • 3
  • 13
  • 27

1 Answers1

0

You can delay the execution of code with Thread.Sleep(). However, in your case, you might want to use the WebBrowser.LoadCompleted-Event. This is an event that fires every time a page finishes loading in the webbrowser. Here's an example of how to use it.

Community
  • 1
  • 1
Dominik B
  • 125
  • 1
  • 12