I expect that if I use a fire and forget Task in ASP.NET like below:
Task.Run(() => { throw new NullReferenceException(); });
Thread.Sleep(100);
GC.Collect();
GC.WaitForPendingFinalizers();
and have the following in Web.config:
<ThrowUnobservedTaskExceptions enabled="true"/>
then I should crash the IIS worker process. However, it does not and I do not understand why. If I start a new thread, it indeed crashes the process:
var thread = new Thread(() => { throw new NullReferenceException(); });
thread.Start();
Thread.Sleep(100);
Why is the Task not causing the process to crash?