如何使正在进行的操作 WebBrowserDocumentCompleted 在单独的线程中工作。所以它不会影响主窗体(不会挂起整个应用程序)
表格1
private void bStart_Click(object sender, EventArgs e)
{
wb.Navigate("http://www.moswar.ru");
}
表格2
public void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
wb = sender as WebBrowser;
ThreadPool.QueueUserWorkItem(new WaitCallback((object unused) =>
{
if (wb.Document.GetElementById("login-email") != null)
{
wb.Document.GetElementById("login-email").InnerText = "myemail@blah.pe";
wb.Document.GetElementById("login-password").InnerText = "MyPassword";
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/");
}
}));
//and so on .....
}