title: Application hangs while waiting for WebBrowser control to complete
body: <p>Why does my application hang until WebBrowserDocumentCompleted completes loading the page? What can I do to keep my application responsive during this time?</p>
  
  <blockquote>
    <p>disabled subscription "<code>DocumentCompleted</code>"</p>
  </blockquote>
  
  <p>The program also freezes during the method <code>wb.Navigate ("http:// ....");</code></p>
  
  <pre><code>Can you post some code to show us what you have done?
  </code></pre>
  
  <p>Clicking a button and go to page</p>
  
  <pre><code>private void ButtonStart_Click(object sender, EventArgs e)
  {
      if (this.settingsForm.tEmail.Text == "" || this.settingsForm.tPassword.Text == "")
      {
          MessageBox.Show("Отсутствует логин и\\или пароль для входа на сервер МосВара.\nВвести их можно, нажав на кнопку \"Настройки\".", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand);
          return;
      }
      wb.Navigate("http://www.moswar.ru");
  }
  </code></pre>
  
  <p><strong>Event handler</strong></p>
  
  <pre><code>private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
  {
      //if (e.Url.AbsolutePath != (sender as WebBrowser).Url.AbsolutePath) return;
      if (wb.Document.GetElementById("login-email") != null)
      {
          wb.Document.GetElementById("login-email").InnerText = settingsForm.tEmail.Text;
          wb.Document.GetElementById("login-password").InnerText = settingsForm.tPassword.Text;
          GetElementsByClassName(new string[] {"button luxury"})[0].InvokeMember("click");
      }
  
      if (e.Url.AbsoluteUri == "http://www.moswar.ru/player/" || e.Url.AbsoluteUri == "http://www.moswar.ru/player/#login")
      {
          wb.Navigate("http://www.moswar.ru/metro/");
      }
  }
  </code></pre>