c# - How to handle different Task exceptions with Wait() of parent and child.ContinueWith? -


i have hierarchy of parent/child tasks:

var t1 = task.factory.startnew(() =>     {         var t21 = task.factory.startnew(() =>             {                 throw new exception("inner fault");             }, taskcreationoptions.attachedtoparent);          var t22 = t21.continuewith(ant =>             {                 console.writeline("inner handler: " + ant.exception.innerexception.message);             }, taskcontinuationoptions.attachedtoparent | taskcontinuationoptions.onlyonfaulted);          throw new exception("outer fault");     });  try {     t1.wait(); } catch (aggregateexception ae) {     foreach (var e in ae.flatten().innerexceptions)         console.writeline("outer handler: " + e.message); } 

as result, "outer handler" handles exception had been handled "inner handler":

inner handler: inner fault outer handler: outer fault outer handler: inner fault 

is possible prevent handling of handled exceptions in "outer handle" ("inner handler" in example)?

it works if remove taskcreationoptions.attachedtoparent on t21.

in case may want add t22.wait() in t1 reproduce behavior of attached child task.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -