Ejemplo n.º 1
0
        private async void btnAsyncProcessWithCancellationToken_Click(object sender, RoutedEventArgs e)
        {
            ProcessEngine processEngine = new ProcessEngine();
            var           results       = await processEngine.ExecuteProcessAsyncWithCancellation(cts.Token);

            TextBlockResult.Text = "RESULT IS " + results.ToString();
            if (cts.IsCancellationRequested)
            {
                cts.Dispose();
                cts = new CancellationTokenSource();
            }
        }
Ejemplo n.º 2
0
        private async void btnAsyncProcess_Click(object sender, RoutedEventArgs e)
        {
            var           watch         = System.Diagnostics.Stopwatch.StartNew();
            ProcessEngine processEngine = new ProcessEngine();

            var results = await processEngine.ExecuteProcessAsync();

            DisplayResult(results);

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

            TextBlockResult.Text += $"Total execution time: { elapsedMs }";
        }
Ejemplo n.º 3
0
        private async void btnAsyncProcessWithCallback_Click(object sender, RoutedEventArgs e)
        {
            Progress <ProgressReportModel> progress = new Progress <ProgressReportModel>();

            progress.ProgressChanged += Progress_ProgressChanged;;

            var watch = System.Diagnostics.Stopwatch.StartNew();

            ProcessEngine processEngine = new ProcessEngine();

            var results = await processEngine.ExecuteProcessAsyncWithCallback(progress);

            PrintResults(results);

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

            TextBlockResult.Text += $"Total execution time: { elapsedMs }";
        }