Create, but not run a task with a custom factory task?

I would like to create a task without starting it, similar to running var a = new Task(); a.Start(); var a = new Task(); a.Start(); but with a custom factory. Factories provide StartNew() , but I cannot find a way to separate these two actions. Is it possible?

+7
source share
1 answer

A TaskFactory is basically two sets of default parameters (create and continue), a default undo marker, and a task scheduler.

You can specify the undo marker and creation options when you just created the task, and then run it on any scheduler you want. So:

 Task task = new Task(action, factory.CancellationToken, factory.CreationOptions); ... task.Start(factory.Scheduler); 

must complete a task different from the continuation options. Continuation options apply only if you add a continuation in any case that you can specify directly. Is there something that is not covered by this?

(It should be noted that a task-based asynchronous template usually revolves around hot tasks that run by the time you see them anyway. Therefore, you probably want to avoid opening up too many non-standard tasks.)

+14
source

All Articles