How to run a Task on a custom TaskScheduler using await?

后端 未结 5 1849
暖寄归人
暖寄归人 2020-11-28 05:24

I have some methods returning Task on which I can await at will. I\'d like to have those Tasks executed on a custom TaskScheduler

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 05:44

    Can you fit for this method call:

      await Task.Factory.StartNew(
            () => { /* to do what you need */ }, 
            CancellationToken.None, /* you can change as you need */
            TaskCreationOptions.None, /* you can change as you need */
            customScheduler);
    

提交回复
热议问题