Creating an attached child Task in .NET C#
August 3, 2017 Leave a comment
A child Task, a.k.a a nested Task, is a Task that’s started within the body of another Task. The containing Task is called the parent.
We saw here how to create detached child Tasks. They are not very interesting really. An attached child Task however is one which has a special relationship with the parent:
- The parent waits for the child to finish before it completes
- If the child Task throws an exception then the parent will catch it and re-throw it
- The status of the parent depends on the status of the child
This is how you attach a child task to a parent: