.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

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -