Sai Avinash
Sai Avinash

Reputation: 4753

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.

Upvotes: 3

Views: 524

Answers (1)

usr
usr

Reputation: 171206

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.

Upvotes: 4

Related Questions