// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; //using System.Threading; // for 3.5 with PFX kit using System.Threading.Tasks; // for 4.0 beta 2 public class MainClass { public static void Main(string[] args) { int[] a = new int[1000]; int[] b = new int[1000]; Parallel.For(0, a.Length, (i) => { a[i] = i; } ); Parallel.For(0, b.Length, (i) => { b[i] = a[i] + 1; } ); Parallel.ForEach(b, (bv) => { if(bv <= 0) throw new Exception("Ooops"); } ); Console.WriteLine(b[77]); } }