点击停止按钮时,我试图关闭程序。
我正在使用后台工作程序,但每当我点击停止时,表单都会挂起,然后我收到一条错误消息“WebDriver.dll中出现类型'OpenQA.Selenium.WebDriverException'的异常但未在用户代码中处理“
我的停止按钮点击代码是
private void button2_Click(object sender, EventArgs e)
{
if (backgroundWorker1.WorkerSupportsCancellation)
{
backgroundWorker1.CancelAsync();
}
Application.Exit();
driverGC.Quit();
}
RunWorkerCompleted是:
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Cancelled)
{
MessageBox.Show("You've cancelled the backgroundworker!");
}
else if (e.Error != null)
{
MessageBox.Show("Error:" + e.Error.Message);
}
else
{
MessageBox.Show("Done!");
}
}
是的,我支持取消。有什么想法吗?
答案 0 :(得分:0)
你试过了吗?
this.Application.Close();