diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.threading.cancellationtokensource.class/cs/cancel1.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.threading.cancellationtokensource.class/cs/cancel1.cs index d736d325f84..7420f0c451b 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.threading.cancellationtokensource.class/cs/cancel1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.threading.cancellationtokensource.class/cs/cancel1.cs @@ -20,43 +20,43 @@ public static void Main() for (int taskCtr = 0; taskCtr <= 10; taskCtr++) { int iteration = taskCtr + 1; tasks.Add(factory.StartNew( () => { - int value; - int[] values = new int[10]; - for (int ctr = 1; ctr <= 10; ctr++) { - lock (lockObj) { - value = rnd.Next(0,101); - } - if (value == 0) { - source.Cancel(); - Console.WriteLine("Cancelling at task {0}", iteration); - break; - } - values[ctr-1] = value; - } - return values; - }, token)); + int value; + int[] values = new int[10]; + for (int ctr = 1; ctr <= 10; ctr++) { + lock (lockObj) { + value = rnd.Next(0,101); + } + if (value == 0) { + source.Cancel(); + Console.WriteLine("Cancelling at task {0}", iteration); + break; + } + values[ctr-1] = value; + } + return values; + }, token)); } try { Task fTask = factory.ContinueWhenAll(tasks.ToArray(), - (results) => { - Console.WriteLine("Calculating overall mean..."); - long sum = 0; - int n = 0; - foreach (var t in results) { - foreach (var r in t.Result) { - sum += r; - n++; - } - } - return sum/(double) n; - } , token); + (results) => { + Console.WriteLine("Calculating overall mean..."); + long sum = 0; + int n = 0; + foreach (var t in results) { + foreach (var r in t.Result) { + sum += r; + n++; + } + } + return sum/(double) n; + } , token); Console.WriteLine("The mean is {0}.", fTask.Result); } catch (AggregateException ae) { foreach (Exception e in ae.InnerExceptions) { if (e is TaskCanceledException) Console.WriteLine("Unable to compute mean: {0}", - ((TaskCanceledException) e).Message); + ((TaskCanceledException) e).Message); else Console.WriteLine("Exception: " + e.GetType().Name); } @@ -99,4 +99,4 @@ public static void Main() // // Calculating overall mean... // The mean is 4.86545454545455. -// \ No newline at end of file +//