.net - Can I make an exception in Task.Run crash the program? -


i'm not big fan of quietly swallowed exceptions, following code that:

task.run(() => {     var obj = dosomethingcpuintensive(); // returns null, due bug     obj.domorestuff();     console.writeline("after"); // never here; program continues running }); 

i've read throwunobservedtaskexceptions configuration value, doesn't help, since never task returned (edit: help, in release builds).

is there way make unhandled exception crash program? using task.run in way i'm not supposed to?

it appears using task.run is, indeed, mistake. think i'm supposed await it, else silly things above happen.

when crash await, debugger rather unhelpful, looking this:

                enter image description here

i take mean i'm doing wrong thing task.run here.

a simple fix use old threadpool.queueuserworkitem instead:

                  enter image description here

that's better! didn't need async/await in code anyway; used task.run because it's less typing.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -