I am copying large amounts of files from one server to several other servers.
I have a list of copy operations which have an Order so The files to Server a are first in the list and the files to server b come at the end of the list.
I am using a AsParallel.AsOrdered() on the list to make sure that files are copied to the first server first then only when threads are free to the second server.
It Doesn't seem to be working as it will copy files to both servers at the same time, am I missing something, is there a better way of writing this code. I checked with large files to really see the order and it seems to not relect the list order
var dotheCopy = copy.ToArray().OrderBy(a => a.GroupId);
var copyList = new List<CopyOps>();
foreach (var x in dotheCopy)
{
... some validation code
copyList.Add(x);
}
copyList.AsParallel().AsOrdered().WithDegreeOfParallelism(5)
.ForAll(x => this.DoTheCopy(x));