我想处理Progress
班级中所有未处理的异常,我在其中编写了一些用于错误记录的代码:
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginPoint());
}
catch (Exception myException)
{
//log the unhandled exceptions.
}
}
}
BackgroundWorker
但是没有正确处理中的异常:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
throw new Exception("TEST EXCEPTION!");
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
throw new Exception("I GOT THE EXCEPTION");
}
}
我希望在我的班级中处理异常“我得到...”Progress
,但是当我运行(而不是调试)应用程序时会出现系统的异常对话框。