I have a list of objects and I have to do some elaboration for each one of them, all of this in the least amount of time possible.
Since those elaborations are indipendent from each others, we've decided to do them in parallel with Parallel.ForEach.
Parallel.ForEach(hugeObjectList, new ParallelOptions { MaxDegreeOfParallelism = 50 }, obj => DoSomeWork(obj) ); Since it seems unreasonable to me setting a huge number on ParallelOptions.MaxDegreeOfParallelism (e.g. 50 or 100), how can we find the optimal number of parallel task to crunch this list?
Does Parallel.Foreach start a DoSomeWork on a different core? (so, since we have 4 cores, the correct degree of parallelism would be 4?)
MaxDegreeOfParallelismproperty learn.microsoft.com/en-us/dotnet/api/…Parallel.ForEachin the first place.