What are the ContinueWith default values

1.4k Views Asked by At

What values use ContinueWith(Action<Task> continuationAction) for CancellationToken, TaskContinuationOptions and TaskScheduler and where can I find this in the official documentation?

2

There are 2 best solutions below

0
On BEST ANSWER

MSDN does not explicitly state this but usually when you have method overloads, all other parameters are "default". Let's find this method in .NET source:

public Task ContinueWith(Action<Task, Object> continuationAction)
{
    StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
    return ContinueWith(continuationAction, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None, ref stackMark);
}

So default CancellationToken (that is CancellationToken.None), empty TaskContinuationOptions and current TaskScheduler are used.

0
On

You can look at most of the actual source code for .Net on http://referencesource.microsoft.com/. In your case the exact overload (ContinueWith(Action<Task> continuationAction)) looks like this:

public Task ContinueWith(Action<Task> continuationAction)
{
    StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
    return ContinueWith(continuationAction, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None, ref stackMark);
}

So, for CancellationToken it's default(CancellationToken) which is equivalent to CancellationToken.None.
For TaskContinuationOptions it's TaskContinuationOptions.None.
For TaskScheduler it's TaskScheduler.Current