I am writing a piece of C# .NET software which spawns a bunch of Background Workers. All of the workers immediately go into the "IsBusy" state, however, only 8 are ever processing through their DoWork method at once.
Is there a way to increase how many run at any one time?
This is how the code spawns the Background workers:
foreach (RESTObjectPrintFile t in printFilesList)
{
BackgroundWorker bgWorker = new BackgroundWorker();
bgWorker.DoWork += BgWorker_DoWork;
bgWorker.RunWorkerCompleted += BgWorker_RunWorkerCompleted;
bgWorkerList.Add(bgWorker);
bgWorker.RunWorkerAsync(t);
}
Try the following
ThreadPool.SetMinThreads(20, 20);
Also check this article http://www.albahari.com/threading/#_Optimizing_the_Thread_Pool
At the bottom it says:
The default value is one thread per core.