Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to know number of threads created using TPL?

What I have tried:

Checked degree of parallelism.
Posted
Updated 3-Mar-19 10:39am
Comments
Patrice T 3-Mar-19 21:30pm    
What says the documentation ?

First of all here is the link to the docs for the Task Parallel library. This would be a good place to start with such a very generic question. You should probably examine using a threadpool and setting the maximum threads in the thread pool.

C#
// Limit threadpool size
int workerThreads, completionPortThreads;
ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
workerThreads = 32;
ThreadPool.SetMaxThreads(workerThreads, completionPortThreads);


Without any details of what you're trying to accomplish, what coding language you're using, what code framework you're using, it's going to just about be impossible to provide any kind of meaningful answer.
 
Share this answer
 
According to the documentation, the Task Parallel Library (TPL)[^], "...handles the partitioning of the work, the scheduling of threads on the ThreadPool[^]".

And according toThreadPool[^] documentation, "There is one thread pool per process. Beginning with the .NET Framework 4, the default size of the thread pool for a process depends on several factors, such as the size of the virtual address space. A process can call the GetMaxThreads[^] method to determine the number of threads. The number of threads in the thread pool can be changed by using the SetMaxThreads[^] method. Each thread uses the default stack size and runs at the default priority."
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900