List integers = new List () { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };Parallel.ForEach(integers, (int item, ParallelLoopState state) =>{ if (item > 5) { Console.WriteLine("Higher than 5: {0}, exiting loop.", item); state.Stop(); } else { Console.WriteLine("Less than 5: {0}", item); }});