dotnetavalanche
dotnetavalanche

Reputation: 890

Check the Number of threads available in ThreadPool at any time

Where and how to check through code number of threads available in threadpool.

What i want is: For example if no of threads in threadpool are 10 then at any given time I should not be using say more than 3 threads. Once an existing thread gets free, I should start a new task, keeping max count 3.

Upvotes: 14

Views: 15225

Answers (1)

kiran
kiran

Reputation: 446

ThreadPool.GetAvailableThreads will give you number of available threads. ThreadPool.GetMaxThreads will give you max number of threads. The difference will give you the number of active threads.

Upvotes: 20

Related Questions