This just a simple code snippet for a practical use, especially batch job sort of things.
public static class Extensions
{
public static void ParallelForEach<T>(this List<T> list, Action<T> action)
{
list.ForEach(item => new Thread(() => action(item)).Start());
}
}
`</pre>
This can be used like:
<pre>`var inputs = new List<string>()
{
"abc.csv",
"xyz.csv",
};
inputs.ParallelForEach(path => ProcessBatchFile(path));
// Assuming a method, ProcessBatchFile, is already defined.