简体   繁体   中英

LongRunning + AttachedToParent (simultaneously) task

My Task have to work for a long time (it's like a service) - so I need to make it LongRunning .

At the same time, I need to mark it as AttachedToParent to prevent parent task completion before my service's task completion.

How to combine this two task creation options?

You can create the task with several creation option: ie.

var task3 = new Task(() => MyLongRunningMethod(),
                TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness);
task3.Start();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM