Parallelization is performed at runtime based on current conditions and many other circumstances. You cannot force .NET to use all cores (at least in managed code).
From MSDN :
"Conversely, by default, the Parallel.ForEach and Parallel.For methods can use a variable number of tasks. Therefore, for example, the ParallelOptions class has the MaxDegreeOfParallelism property instead of the" MinDegreeOfParallelism "property. That the system can use fewer threads than request loop processing. Thread pool .NET dynamically adapts to changing workloads, allowing you to change the number of workflows for concurrent tasks over time, while the system monitors whether the number of threads increases or worsens the overall flow. accelerated ability and accordingly adjusts the number of work flows.
Be careful if you use parallel loops with separate steps that take a few seconds or more. This can happen with workloads related to I / O, as well as lengthy calculations. If loops take a lot of time, you may encounter unlimited growth in workflows due to heuristics to prevent starvation used by Thread Thread's threading logic. "
source share