Scenario
I have a background worker in my application that runs away and does a bunch of processing. I specifically used this implementation to maintain fluid in the user interface and prevent it from freezing. I want to keep the background worker, but ONLY 3 LARGE threads are posted inside this thread - forcing them to share processing (currently the worker thread is just outlines and processes each asset one at a time. However, I would like to speed up this process but using only a limited number of threads.
Question
Given the code below, how can I get a loop to select a thread that is free, and then essentially wait if it is not released before continuing.
CODE
foreach (KeyValuePair<int, LiveAsset> kvp in laToHaganise)
{
Haganise h = new Haganise(kvp.Value,
busDate,
inputMktSet,
outputMktSet,
prodType,
noOfAssets,
bulkSaving);
h.DoWork();
}
Thoughts
, 3 , , Haganise - "h" .....
Thread firstThread = new Thread(new ThreadStart(h.DoWork));
Thread secondThread =new Thread(new ThreadStart(h.DoWork));
Thread thirdThread = new Thread(new ThreadStart(h.DoWork));
.