Esempio n. 1
0
        private async void OnExecuteAsync(object obj)
        {
            Total = 0;
            cts   = new CancellationTokenSource();
            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)
            {
                ResultsText += $"The async download was cancelled. { Environment.NewLine }";
            }

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

            ResultsText += $"Total execution time: { elapsed }";
        }
Esempio n. 2
0
        private async void OnExecuteParallelAsync(object obj)
        {
            Total = 0;
            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;

            ResultsText += $"Total execution time: { elapsedMs }";
        }