What are the default ContinueWith values

What values ​​are used ContinueWith(Action<Task> continuationAction)

for CancellationToken

, TaskContinuationOptions

and TaskScheduler

and where can I find this in the official documentation?

+3


source to share


2 answers


MSDN does not explicitly state this, but usually all other parameters are "default" when a method is overloaded. Let's find this method in the .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, by default CancellationToken

(that is CancellationToken.None

), empty TaskContinuationOptions

and current TaskScheduler

.

+6


source


You can view most of the .Net source code at http://referencesource.microsoft.com/ . In your case, the exact overload of ( 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 default(CancellationToken)

, which is equivalent CancellationToken.None

.
For TaskContinuationOptions

it TaskContinuationOptions.None

.
For TaskScheduler

itTaskScheduler.Current

+1


source







All Articles