【发布时间】:2011-09-21 20:55:45
【问题描述】:
我完全不解。如果我从未测试过的线程中存在未捕获的异常,我非常确定 .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();
}
【问题讨论】:
标签: c# .net multithreading exception-handling delegates