简体   繁体   中英

How to handle long running process using TPL

I have started learning TPL in C# recently. We have a windows service that does some functionality.

I have to perform each job paralelly rather than  sequentially.

Each job will be taking more than 10 mins to complete . So, i am considering this as long running process.

So, i guess i would not be creating ThreadPool for this , as it is meant for short time threads.

how to handle long running tasks using TPL. Suppose if i have 100 jobs to process,

Do i need to create 100 tasks for long running process ?

Please clarify on above.

Use TaskCreationOptions.LongRunning . It is made for long-running work that might confuse the thread-pool heuristics. As of .NET 4.5 this always runs your code on a new thread. You can still use all other TPL features.

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