title: Why does my Parallel.ForAll call end up using a single thread?
body: <p>I have been using PLINQ recently to perform some data handling.</p>
  
  <p>Basically I have about 4000 time series (so basically instances of <code>Dictionary&lt;DataTime,T&gt;</code>) which I stock in a list called <code>timeSeries</code>.</p>
  
  <p>To perform my operation, I simply do:</p>
  
  <pre><code>timeSeries.AsParallel().ForAll(x=&gt;myOperation(x))
  </code></pre>
  
  <p>If I have a look at what is happening with my different cores, I notice that first, all my CPUs are being used and I see on the console (where I output some logs) that several time series are processed at the same time.</p>
  
  <p>However, the process is lengthy, and after about 45 minutes, the logging clearly indicates that there is only one thread working. Why is that?</p>
  
  <p>I tried to give it some thought, and I realized that <code>timeSeries</code> contains instances simpler to process from <code>myOperation</code>'s point of view at the beginning and the end of the list. So, I wondered if maybe the algorithm that PLINQ was using consisted in splitting the 4000 instances on, say, 4 cores, giving each of them 1000. Then, when the core is finished with its allocation of work, it goes back to idle. This would mean that one of the core may be facing a much heavier workload.</p>
  
  <p>Is my theory correct or is there another possible explanation?</p>
  
  <p>Shall I shuffle my list before running it or is there some kind of parallelism parameters I can use to fix that problem?</p>