I'm not a big fan of quietly swallowed exceptions, but the following code does exactly that:
Task.Run(() =>
{
var obj = DoSomethingCpuIntensive(); // returns null, due to a bug
obj.DoMoreStuff();
Console.WriteLine("after"); // never get here; program continues running
});
I've read about the ThrowUnobservedTaskExceptions configuration value, but this doesn't help, since I never do anything with the Task
returned (edit: actually it does help, but only in Release builds).
Is there a way to make that unhandled exception crash the program? Am I using Task.Run
in a way I'm not supposed to?