Is there any way of duplicating the functionality found within the combinable data structure within C++ in C#?
In C++ I could do something along the lines of:
Concurrency::combinable<CustomData> c;
Concurrency::parallel_for(0, size, [&](int i)
{
CustomData cd = some_operation(i);
c.local() += cd;
});
c.combine([](CustomData a, CustomData b) { return a + b; });
Where CustomData is some arbitrary data that has a well def开发者_如何学编程ined addition operator.
Any help would be much appreciated!
check out PLINQ and the Aggregate method. it's awesome. http://msdn.microsoft.com/en-us/library/dd460697.aspx
精彩评论