の例と混同しています
http://msdn.microsoft.com/en-us/library/dd997393.aspx
Parallel.ForEach<int, long>(nums, // source collection
() => 0, // method to initialize the local variable
(j, loop, subtotal) =>
{
subtotal += nums[j];
return subtotal;
},
(finalResult) => Interlocked.Add(ref total,finalResult) );
最後のデリゲート(finalResult) => Interlocked.Add(ref total,finalResult)
がインターロックを必要とする理由がわかりませんが、前の式は
(j, loop, subtotal) =>
{
subtotal += nums[j];
return subtotal;
},
ではない?
ありがとう