It could be beneficial to run multiple threads to perform operations on different segments concurrently, so that certain tasks can be completed quicker (like some data updates using some services), and Data Parallelism could help you, and in this scenario you can benefit from a powerful processor by writing a code as follows;
For debugging purposes; you can replace the ParallelForEach with this following line to your checks for certain items;
ParallelOptions
options = new ParallelOptions() {
MaxDegreeOfParallelism = System.Environment.ProcessorCount };
Parallel.ForEach(mdList.AsEnumerable(),
options, async row =>
{
result = await ProcessATask(param);
});
For debugging purposes; you can replace the ParallelForEach with this following line to your checks for certain items;
Parallel.ForEach(mdList.Select(“numbertocheck”).AsEnumerable(),
options, async row =>
{
result = await ProcessATask(param);
});
Comments
Post a Comment