Is it possible to force a task to execute synchronously, on the current thread?
That is, is it possible, by e.g. passing some parameter to StartNew()
, to ma
Task scheduler decides whether to run a task on a new thread or on the current thread. There is an option to force running it on a new thread, but none forcing it to run on the current thread.
But there is a method Task.RunSynchronously()
which
Runs the Task synchronously on the current TaskScheduler.
More on MSDN.
Also if you are using async/await
there is already a similar question on that.