3
Answers

usage of Parallel.For

Henri de Feraudy

Henri de Feraudy

10y
781
1
Hello,
  I havent done much C# over the last years, so you can imagine that when I land upon Parallel.For I am a bit lost. The arguments start with two numbers separated by commas, looks like the limits, then comes
a lambda expression 
() => new Locals { TheArray = new uint[arraySize], SrcArray = new uint[arraySize] },
and then (after that comma)
delegate(int y, ParallelLoopState state, CombineLocals locals) 
and then a block inside {}
and finally
, locals => { });
I've uploaded the code 
Now here are some questions: Im using the C# 5.0 in a nutshell as my guide and it just talks of a Parallel for loop as having the following syntax: 
Parallel.For(from, to, Function)
now the above code doesnt really fit into that: there is a lambda expression and then what seems to be an anonymous function that begins wth a delegate(...). It looks like these would be executed sequentially, but I'm not sure. Am I right on this point? The second point is that there seems to be a lambda followed by an anonymous function. I thought anonymous functions had been made redundant by lambda functions. Am I wrong?
Finally what is locals=>{} doing here??
Thankyou for your attenion.




Answers (3)