【问题标题】:Analong of Concurrency::combinable<T> in C#?C# 中 Concurrency::combinable<T> 的模拟?
【发布时间】:2011-01-19 20:49:09
【问题描述】:

有没有办法在 C# 中复制 C++ 中可组合数据结构中的功能?

在 C++ 中,我可以执行以下操作:

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; });

其中 CustomData 是一些具有明确定义的加法运算符的任意数据。

任何帮助将不胜感激!

【问题讨论】:

    标签: c# multithreading concurrency


    【解决方案1】:

    查看 PLINQ 和 Aggregate 方法。这很棒。 http://msdn.microsoft.com/en-us/library/dd460697.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-27
      • 2011-10-21
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-24
      相关资源
      最近更新 更多