public static void Menu() { var ct = new CancellationTokenSource(); Console.WriteLine("Sync, Async and Parallel Console Test"); Console.WriteLine(); Console.WriteLine("Menu"); Console.WriteLine("1 - Sync"); Console.WriteLine("2 - Async"); Console.WriteLine("3 - ParallelSync"); Console.WriteLine("4 - ParallelAsync"); Console.WriteLine("Any Other - Exit"); var key = Console.ReadLine(); Action method = key switch { "1" => () => Logging(Sync.RunDownloadSync()), "2" => async() => Logging(await Async.RunDownloadAsync(ct.Token)), "3" => () => Logging(ParallelSync.RunDownloadParallelSync()), "4" => async() => Logging(await ParallelAsync.RunDownloadParallelASync(ct.Token)), _ => null }; if (method != null) { method.Invoke(); Menu(); } }
private void btnParallelSync_Click(object sender, RoutedEventArgs e) { InitTest("PARALLEL SYNC"); results = ParallelSync.RunDownloadParallelSync(); EndTest(); }