I tried to find an answer for this but couldn\'t. What I was wondering is that on which thread Task.ContinueWith
delegate is called.
For await I know that it tr
Task.ContinueWith
is scheduled on the TaskScheduler.Current
unless specified otherwise by the parameters in one of the optional overloads.
If you don't have a custom scheduler in TaskScheduler.Current
(which is very likely) your continuation will run on the ThreadPool
.
Task.ContinueWith
never uses the SynchronizationContext
unless you create a TaskScheduler
out of it with TaskScheduler.FromCurrentSynchronizationContext
.
You can always state explicitly which TaskScheduler
is needed using one of the available overloads:
task.ContinueWith(
_ => {},
null,
CancellationToken.None,
TaskContinuationOptions.None,
TaskScheduler.Default); // Scheduled to the ThreadPool