Пример #1
0
        async void StartTimedTaskClicked(object sender, System.EventArgs e)
        {
            CancellationTokenSource = new CancellationTokenSource();
            CancellationTokenSource.CancelAfter(3000);
            var   task = UltraComplexLibrary.SlowTask(this, CancellationTokenSource.Token);
            await task;

            if (task.Exception != null)
            {
                IntegerReport.Text = "Excepción";
            }
        }
Пример #2
0
        async void StartTaskClicked(object sender, System.EventArgs e)
        {
            CancellationTokenSource = new CancellationTokenSource();
            var task = UltraComplexLibrary.SlowTask(this, CancellationTokenSource.Token);

            try
            {
                await task;
            }
            catch (OperationCanceledException op)
            {
            }
            finally
            {
                IntegerReport.Text = task.Status.ToString();
            }
        }