List ForEach break
问题 is there a way to break out of the foreach extension method? The "break" keyword doesn't recognize the extension method as a valid scope to break from. //Doesn't compile Enumerable.Range(0, 10).ToList().ForEach(i => { System.Windows.MessageBox.Show(i.ToString()); if (i > 2)break; }); Edit: removed "linq" from question note the code is just an example to show break not working in the extension method... really what I want is for the user to be able to abort processing a list.. the UI thread