private async void executeAsync_Click(object sender, RoutedEventArgs e) { Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>(); progress.ProgressChanged += ReportProgress; var watch = 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}"; }
private void executeSync_Click(object sender, RoutedEventArgs e) { var watch = Stopwatch.StartNew(); PrintResults(DemoMethods.RunDownloadSync()); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; resultsWindow.Text += $"Total execution time : {elapsedMs} {Environment.NewLine}"; }
private async void executeParallelAsync_Click(object sender, RoutedEventArgs e) { var watch = Stopwatch.StartNew(); var results = await DemoMethods.RunDownloadParallelAsync(); 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 = Stopwatch.StartNew(); var results = await DemoMethods.RunDownloadParallelAsyncV2(progress); PrintResults(results); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; resultsWindow.Text += $"Total execution time : {elapsedMs}"; }