Thor Burfine Thor Burfine - 7 days ago 4
C# Question

Threading in blocks

I have a list of IDs , lets say 1,000 of them.

I need to start a thread for each one with a max of 10 running at any time

I thought of using paging on a Linq result set but I would loose the running of 10 all the time.

Any suggestions on how I can keep 10 threads running at all times until all records are processed


I suggest using Parallel Linq (PLinq), something like this:

List<int> IDs = ...

  .ForAll(id => /*TODO: put relevant code here*/ );