我有一个 Web API 应用程序,其中包含此方法
public class TestController
{
public UserView Get()
{
var testThread = new Thread(() => { throw new Exception(); });
testThread.Start();
Thread.Join();
Thread.Sleep(1000);
return null;
}
}
当我请求这个方法时,我的应用程序池会崩溃。我会收到这个窗口
![enter image description here](https://istack.dev59.com/vD7Sv.webp)
![enter image description here](https://istack.dev59.com/r4rWW.webp)
var task = new Task(() => { throw new Exception(); });
task.Start();
一切都很好。为什么?