【发布时间】:2015-01-20 12:17:46
【问题描述】:
好的,这应该是基本的,但我找不到好的答案。 我只想在 BackgroundWorker 内抛出的异常中进行 VS 中断。 代码示例:
private void btnBGWorker_Click(object sender, EventArgs e)
{
BackgroundWorker bgWorker = new BackgroundWorker();
bgWorker.DoWork += bgWorker_DoWork;
bgWorker.RunWorkerCompleted += bgWorker_RunWorkerCompleted;
bgWorker.RunWorkerAsync();
}
void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//I know e.Error have the Exception but
if (e.Error != null)
throw e.Error; //Well this does not work, VS will throw TargetInvocationException
}
void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
//** How can I make VS break here !!!??? **
throw new NotImplementedException();
}
【问题讨论】:
标签: c# exception backgroundworker