How do I break out of an parallel.for loop?
I have a pretty complex statement which looks like the following:
Parallel.ForEach<ColorIndexHolder>(ColorIndex.AsEnumerable(),
new Action<ColorIndexHolder>((ColorIndexHolder Element) =>
{
if (Element.StartIndex <= I && Element.StartIndex + Element.Length >= I)
{
Found = true;
break;
}
}));
Using parallel class, I can optimize this process by far. However; I cannot figure out how to break the parallel loop? The break;
statement throws following syntax error:
No enclosing loops out of which to break or continue
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…