How to get the maximum degree of parallelism for using a parallel task library?

I want to use Parallel.invoke. If I assign 20 parallel tasks, only 8 of them will be executed at a time. My processor is http://ark.intel.com/products/47925 , and the number of messages is 8. I assume that the number of tasks can be performed in parallel, related to the number of thread processors. I do not want to create more tasks than the number of threads. How to find out the number of threads in C #? I tried the ParallelOptions.MaxDegreeOfParallelism request, and everything I get is -1.

+4
source share
1 answer

Parallel tasks are basically threads that can be shared. Since the number of active threads is limited by the number of available logical processor cores, we can assume that it is simply the number of logical cores available for the program.

Environment.ProcessorCount
+5
source

Source: https://habr.com/ru/post/1524994/


All Articles