Candy Chiu Candy Chiu - 7 months ago 102
C# Question

How to ContinueWith antecedent's state object?

Is there a way to pass a state object to the ContinueWith function in .net 4.0? This option is available in .net 4.5.

I reviewed the source code of .net 4.0, it hard codes the state object to null when it creates the continued Task.


The .NET 4 version of ContinueWith does not provide this option.

You can, however, use a closure or wrap the data into the Task<T> itself, depending on how this is generated, in order to get access to state data created within the antecedent task.