c# - Nested Parallel.ForEach Loops on the same list? -


I need to concoct a method that compares the entire joints with elements in a list, serial implementation directly - Next:

  foreach (var element1 in list) foreach (var element2 in list) foo (element1, element2);  

In this case, the foo will not change the position of element 1 or element2. I know that this is not just parallel nested. ForEach statement:

  parallel. Foreike (list, representative (A element 1) {parallel. (The list, representative (A element 2) {EF (Element1, element2);});});  

What would be the ideal way to implement this with the use of parallel work libraries?

Do not have a parallel and a normal loop? Either

 parallel.forh (list, representative (A element 1) {foreach (an element 2 in the list) foo (element1, element2)}); 

or

 (one element in the list) {parallel. Forum (list, representative (A element 2) {eff (element 1, element 2);}); } 

It should also be sharpened every time the thread could not be threaded, so it will probably be faster or slightly slower than the nested parallel loops.


Comments