I have the following code in a console app:

foreach (string str in _betterStrings)
{
doSomething(str);
}

AddRangeButNoDuplicates(_betterStrings, _goodStrings);
I would like to add multi-threading, so that there is a CommandLine parameter which specifies the maximum threads, then spawns new threads which execute the doSomething(). As each thread completes, a new thread needs to be spawned, keeping the console app running at the maximum number of threads.

If there is anyone on this board that has done this, I would greatly appreciate it if you could point me in the best direction.

Thanks in advance.