Search code examples
c#multithreadingparallel-processingtask-parallel-libraryconceptual

Why do we need ContinueWith method?


Why do we need Task.ContinueWith() method. Cannot we just write that "continuation code" inside Task body?


Solution

  • Sometimes you receive a Task from the outside and want to chain your continuation to it. There are also ways to create a task without an Action (e.g. using TaskCompletionSource).