Thor Burfine Thor Burfine - 11 months ago 47
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

Answer Source

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

List<int> IDs = ...

  .ForAll(id => /*TODO: put relevant code here*/ );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download