The work I'm trying to schedule is using the await
keyword, hence the work itself is of type async Task
.
I can't use Task.Factory.StartNew
, even when I pass my scheduler, because it will consider the task "done" when it hits the first await of the work, making it leave the scheduler and continuing on the default scheduler.
I can't use var a = new Task(DoWork....); a.Start(myScheduler)
, because I'd be using an async void
method, and we know the pitfalls to that.
I can't use Task.Run()
, because it doesn't allow you to change the scheduler on which the task will be scheduled to launch.
If I can't use any of that, how will I achieve my goal, which is to schedule my async Work, which has to complete execution on the scheduler it was initially started on?