private void executeSync_Click(object sender, RoutedEventArgs e) { var watch = System.Diagnostics.Stopwatch.StartNew(); var results = DemoMethods.RunDownloadParallelSync(); PrintResults(results); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; resultsWindow.Text += $"Total execution time: { elapsedMs }"; }
private async void executeParallelAsync_Click(object sender, RoutedEventArgs e) { Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>(); progress.ProgressChanged += ReportProgress; var watch = System.Diagnostics.Stopwatch.StartNew(); var results = await DemoMethods.RunDownloadParallelAsyncV2(progress); PrintResults(results); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; resultsWindow.Text += $"Total execution time: { elapsedMs }"; }
private async void executeAsync_Click(object sender, RoutedEventArgs e) { Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>(); progress.ProgressChanged += ReportProgress; var watch = System.Diagnostics.Stopwatch.StartNew(); try { var results = await DemoMethods.RunDownloadAsync(progress, cts.Token); PrintResults(results); } catch (OperationCanceledException) { resultsWindow.Text += $"The async download was cancelled. { Environment.NewLine }"; } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; resultsWindow.Text += $"Total execution time: { elapsedMs }"; }