.net - When do exceptions from fire and forget Tasks get raised in the calling thread? -


according msdn:

if not wait on task propagates exception, or access exception property, exception escalated according .net exception policy when task garbage-collected. when exceptions allowed bubble joining thread, possible task may continue process items after exception raised.

i assumed task class has finalizer raises exception or something. why following seem run indefinitely?

long collectioncount = 0;  task.factory.startnew(() => { throw new notimplementedexception(); });  while (true) {     gc.collect();     gc.waitforpendingfinalizers();     ++collectioncount; } 

since .net framework 4.5, unobserved exceptions tasks no longer crash process when finalized. means code running on .net 4.5 (or newer) , you're getting new, non-crashing behavior.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -