Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2012-04-03 15:17:07 +0400
committerMarek Safar <marek.safar@gmail.com>2012-04-03 16:43:19 +0400
commitec47a5a91200db692ec9a671747984190ee3bfa6 (patch)
tree568bb22a4b86fe80e89026f445d6d6c5ad58e8b8 /mcs/tests/test-async-32.cs
parent474544b3bb262e2da690598baafa66789eeaffea (diff)
Better handling of OperationCanceledException
Diffstat (limited to 'mcs/tests/test-async-32.cs')
-rw-r--r--mcs/tests/test-async-32.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/mcs/tests/test-async-32.cs b/mcs/tests/test-async-32.cs
new file mode 100644
index 00000000000..7c319926884
--- /dev/null
+++ b/mcs/tests/test-async-32.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+class Program
+{
+ static async Task<int> TestCanceled()
+ {
+ await Task.FromResult(1);
+ throw new OperationCanceledException();
+ }
+
+ static async Task TestCanceled_2()
+ {
+ await Task.FromResult(1);
+ throw new OperationCanceledException();
+ }
+
+ static async Task<int> TestException()
+ {
+ await Task.FromResult(1);
+ throw new ApplicationException();
+ }
+
+ static int Main()
+ {
+ bool canceled = false;
+ var t = TestCanceled().ContinueWith(l =>
+ {
+ canceled = l.IsCanceled;
+ }, TaskContinuationOptions.ExecuteSynchronously);
+
+ t.Wait();
+
+ if (!canceled)
+ return 1;
+
+ if (t.Exception != null)
+ return 2;
+
+ t = TestCanceled_2().ContinueWith(l =>
+ {
+ canceled = l.IsCanceled;
+ }, TaskContinuationOptions.ExecuteSynchronously);
+
+ t.Wait();
+
+ if (!canceled)
+ return 11;
+
+ if (t.Exception != null)
+ return 12;
+
+ bool faulted = false;
+ t = TestException().ContinueWith(l =>
+ {
+ faulted = l.IsFaulted;
+ }, TaskContinuationOptions.ExecuteSynchronously);
+
+ if (!faulted)
+ return 21;
+
+ if (t.Exception != null)
+ return 22;
+
+ Console.WriteLine("ok");
+ return 0;
+ }
+}