Point of the `antecedent` argument of the argument of `Task.ContinueWith`?

c#, closures, task-parallel-library

Solution

Does the antecedent argument exist only to avoid the allocation of a closure as in the second variant?

Effectively, yes. It also lets you write this more succinctly as:

 Task.Factory.StartNew( () => DoSomething())
             .ContinueWith( t => DoSomethingWith(t));

It also provides a similar API to using `TaskFactory.ContinueWhenAll` or `TaskFactory.ContinueWhenAny`.

Problem

Given a `Task t`, is there any semantic difference between ``` t.ContinueWith(ante => DoSomethingWith(ante)); ``` and ``` t.ContinueWith(ante => DoSomethingWith(t)); ``` , assuming that `t` is not mutated later? Does the `antecedent` argument exist only to avoid the allocation of a closure as in the second variant?

Original source