Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我Task必须工作很长时间(这就像一项服务) - 所以我需要做到LongRunning。
Task
LongRunning
同时,我需要将其标记为AttachedToParent防止在我的服务任务完成之前完成父任务。
AttachedToParent
如何结合这两个任务创建选项?
您可以使用多个创建选项创建任务:即。
var task3 = new Task(() => MyLongRunningMethod(), TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness); task3.Start();