Answer the question
In order to leave comments, you need to log in
C# Parallel.ForEach in Parallel.ForEach. Does it make sense?
Good afternoon. The question is purely theoretical - there is such a piece of code:
ParallelOptions _parallel_options = new ParallelOptions();
_parallel_options.MaxDegreeOfParallelism = _ret.threads_count;
Parallel.ForEach<string>(File.ReadLines(_ret.file_name, _codepage)
, _parallel_options
, (_line, _parallel_state, _index) =>
{
//some code
Parallel.For(0, _idx, (_field_index) =>
{
//some code
});
});
Answer the question
In order to leave comments, you need to log in
It seems to me that in this case you will run into reading from disk
There was a task, I decided to do it in a similar way. As a result, when using such a structure without creating a second thread for the internal Parallel.ForEach, a performance drop was noticed when executing a piece of code. As a result, for my task, it was decided to use only one Parallel.ForEach.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question