我知道,你可以在RunWorkerCompleted處理程序處理BackgroundWorker的錯誤,就像下面的代碼誤差與BackgroundWorker的
var worker = new BackgroundWorker();
worker.DoWork += (sender, e) =>
{
throw new InvalidOperationException("oh shiznit!");
};
worker.RunWorkerCompleted += (sender, e) =>
{
if(e.Error != null)
{
MessageBox.Show("There was an error! " + e.Error.ToString());
}
};
worker.RunWorkerAsync();
但我的問題是,我還收到一條消息:錯誤是在用戶代碼unhadled上線
throw new InvalidOperationException("oh shiznit!");
我該如何解決這個問題?
你在WinFormss應用程序中測試這個嗎?還是控制檯? – 2010-10-19 09:21:40