Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / tests / test-async-32.cs
index 7c3199268846221f141125933d04fcaf5013205f..8942844d0a0ca6689ed8942ae8c953ddc5261303 100644 (file)
@@ -22,7 +22,7 @@ class Program
                throw new ApplicationException();
        }
 
-       static int Main()
+       public static int Main()
        {
                bool canceled = false;
                var t = TestCanceled().ContinueWith(l =>
@@ -52,16 +52,21 @@ class Program
                        return 12;
 
                bool faulted = false;
+               bool has_exception = false;
                t = TestException().ContinueWith(l =>
                {
                        faulted = l.IsFaulted;
+                       has_exception = l.Exception != null; // Has to observe it or will throw on shutdown
                }, TaskContinuationOptions.ExecuteSynchronously);
 
                if (!faulted)
                        return 21;
+                       
+               if (!has_exception)
+                       return 22;
 
                if (t.Exception != null)
-                       return 22;
+                       return 23;
 
                Console.WriteLine("ok");
                return 0;