using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
public static void Main()
Program p = new Program();
Task[] tasks = new Task[2];
for (int i = 0; i < 10; i++)
sw = Stopwatch.StartNew();
Parallel.Invoke(() => p.Gotosleep(), () => p.Gotosleep());
string res = sw.Elapsed.ToString();
Console.WriteLine("Parallel invoke results: " + res);
for (int i = 0; i < 10; i++)
sw = Stopwatch.StartNew();
tasks[0] = Task.Factory.StartNew(() => p.Gotosleep());
tasks[1] = Task.Factory.StartNew(() => p.Gotosleep());
string res2 = sw.Elapsed.ToString();
Console.WriteLine("Task wait all results: " + res2);