为什么我的应用程序会挂起,直到 WebBrowserDocumentCompleted 完成加载页面?在此期间,我可以做些什么来保持我的应用程序响应?
已禁用订阅“
DocumentCompleted
”
该程序也在该方法期间冻结wb.Navigate ("http:// ....");
Can you post some code to show us what you have done?
单击按钮并转到页面
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");
}
事件处理程序
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/");
}
}