2 using System.Threading;
3 using System.Threading.Tasks;
7 static async Task<int> TestCanceled()
9 await Task.FromResult(1);
10 throw new OperationCanceledException();
13 static async Task TestCanceled_2()
15 await Task.FromResult(1);
16 throw new OperationCanceledException();
19 static async Task<int> TestException()
21 await Task.FromResult(1);
22 throw new ApplicationException();
27 bool canceled = false;
28 var t = TestCanceled().ContinueWith(l =>
30 canceled = l.IsCanceled;
31 }, TaskContinuationOptions.ExecuteSynchronously);
38 if (t.Exception != null)
41 t = TestCanceled_2().ContinueWith(l =>
43 canceled = l.IsCanceled;
44 }, TaskContinuationOptions.ExecuteSynchronously);
51 if (t.Exception != null)
55 t = TestException().ContinueWith(l =>
57 faulted = l.IsFaulted;
58 }, TaskContinuationOptions.ExecuteSynchronously);
63 if (t.Exception != null)
66 Console.WriteLine("ok");