我完全不解.如果在我从未测试过的线程中存在未捕获的异常,我非常确定.NET会关闭整个应用程序域.
但是我只是尝试了下面的代码并且它没有失败......任何人都可以解释为什么?
(在.NET 4和3.5中尝试过)
static void Main(string[] args)
{
Console.WriteLine("Main thread {0}", Thread.CurrentThread.ManagedThreadId);
Action a = new Action(() =>
{
Console.WriteLine("Background thread {0}", Thread.CurrentThread.ManagedThreadId);
throw new ApplicationException("test exception");
});
a.BeginInvoke(null, null);
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)