I think the current behavior makes sense. If I create my own task scheduler, and start some task that starts other tasks, I probably want all the tasks to use the scheduler I created.
I agree that it’s odd that sometimes starting a task from the UI thread uses the default scheduler and sometimes not. But I don’t know how would I make this better if I was designing it.
Regarding your specific problems:
- I think the easiest way to start a new task on a specified scheduler is
new Task(lambda).Start(scheduler). This has the disadvantage that you have to specify type argument if the task returns something.TaskFactory.Createcan infer the type for you. - You can use
Dispatcher.Invoke()instead of usingTaskScheduler.FromCurrentSynchronizationContext().