예제 #1
0
        private async void btnCancelThread_Click(object sender, RoutedEventArgs e)
        {
            resultWindow.Text = "";
            var watch = System.Diagnostics.Stopwatch.StartNew();
            Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>();

            progress.ProgressChanged += Progress_ProgressChanged;

            try
            {
                List <WebsiteDataModel> results = await AsyncDemoMethod.RunDownloadAsyncParallelForWithCancel(progress, cts.Token);

                PrintResults(results);
            }
            catch (Exception ex)
            {
                resultWindow.Text += $" Cancelled: {ex.InnerException.Message}. {Environment.NewLine} ";
            }

            watch.Stop();
            var ms = watch.ElapsedMilliseconds;


            resultWindow.Text += $" Toatal execution time: {ms}. {Environment.NewLine} ";
        }
예제 #2
0
        private async void btnAsyncExcute2_Click(object sender, RoutedEventArgs e)
        {
            resultWindow.Text = "";
            var watch = System.Diagnostics.Stopwatch.StartNew();

            List <WebsiteDataModel> results = await AsyncDemoMethod.RunDownloadASyncUsingWebclientAsync();

            watch.Stop();
            var ms = watch.ElapsedMilliseconds;

            PrintResults(results);
            resultWindow.Text += $" Toatal execution time: {ms}. {Environment.NewLine} ";
        }
예제 #3
0
        private async void btnAsyncProgress_Click(object sender, RoutedEventArgs e)
        {
            resultWindow.Text = "";
            var watch = System.Diagnostics.Stopwatch.StartNew();
            Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>();

            progress.ProgressChanged += Progress_ProgressChanged;

            List <WebsiteDataModel> results = await AsyncDemoMethod.RunDownloadAsync(progress);

            watch.Stop();
            var ms = watch.ElapsedMilliseconds;

            PrintResults(results);
            resultWindow.Text += $" Toatal execution time: {ms}. {Environment.NewLine} ";
        }