I am opening n
concurrent threads in my function:
List _files = new List();
public void Start()
{
Cancellation
Of course the files are randomly selected, that's the whole point of parallel.foreach. If you go parallel, the 5 threads you specified will use the input as it's decided by the data partionier.
But if you really want to maintain the order, check the OrderablePartitioner you can specify for the parallel.foreach. -> http://msdn.microsoft.com/en-us/library/dd989583.aspx But of course this will decrease performance, but it allows you to specify how the partitions are created for the threads.