Substitution of the Task class is difficult even if you inherit a new class from Task : since TaskScheduler and TaskFactory are not common for Task , this will not help at all.
In my experience, it's better to use the native TaskScheduler class (inherited from TaskScheduler ). You can pass it to the TaskFactory constructor, and then use its TaskFactory .
Now for testing, you can use another TaskScheduler with varying degrees of parallelism (up to 1 thread, if you want), and you can add an additional log to your TaskScheduler class to register each task as it starts and finishes.
source share