相关疑难解决方法(0)

打破parallel.foreach?

如何打破parallel.for循环?

我有一个非常复杂的声明,如下所示:

Parallel.ForEach<ColorIndexHolder>(ColorIndex.AsEnumerable(),
    new Action<ColorIndexHolder>((ColorIndexHolder Element) =>
    {
        if (Element.StartIndex <= I && Element.StartIndex + Element.Length >= I)
        {
            Found = true;
            break;
        }
    }));
Run Code Online (Sandbox Code Playgroud)

使用并行类,我可以到目前为止优化这个过程.然而; 我无法弄清楚如何打破并行循环?该break;语句抛出以下语法错误:

没有封闭的环可以打破或继续

c# parallel-processing multithreading parallel.foreach

95
推荐指数
5
解决办法
5万
查看次数