I have a large data set of 51 classes (51 folders/directories) each class has 10 different instances (10 sub directories per directory) and each instance has 600 views (600 files of 10 MB each per sub directory).
I am using a jagged array of tasks to read those files in parallel i.e.
Task[][] threads = new Task[51][10];
More use of this can be found here at Jagged array of tasks - Concurrency Issues
Is there any approach better than this one because it calls for unforeseen bugs?
Edit: Posting code from referenced link in case that gets deleted
Task[][] threads = new Task[InstancesDir.Length][];
for (int i = 0; i < InstancesDir.Length; i++)
{
threads[i] = new Task[InstancesDir[i].Length];
}
for (int i = 0; i < FilesDir.Length; i++)
{
for (int j = 0; j < FilesDir[i].Length; j++)
{
threads[i][j] = Task.Run(() =>
{
Calculate(i, j, InstancesDir, FilesDir, PointSum);
});
}
Task.WaitAll(threads[i]);
}