开发者

Task.Factory.StartNew() Taskscheduler parameter

see: TaskFactory

When i want to make a task to be long-running and also to be开发者_运维技巧 cancellable, If i am calling this method from ui, how do i pass the taskscheduler parameter?


It's not really obvious what the problem is. Why can't you just call:

CancellationToken token = new CancellationToken(false);
TaskScheduler scheduler = TaskScheduler.Default;
Task task = taskFactory.StartNew(action, token, 
                                 TaskCreationOptions.LongRunning, scheduler);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜