Update to .NET 4.5 default exception behavior for unobserved exceptions.
authorMarek Safar <marek.safar@gmail.com>
Tue, 29 May 2012 15:12:42 +0000 (16:12 +0100)
committerMarek Safar <marek.safar@gmail.com>
Tue, 29 May 2012 15:13:46 +0000 (16:13 +0100)
mcs/class/corlib/System.Threading.Tasks/TaskExceptionSlot.cs

index 4d7797cf4aed9368f0359dfeadd70cda09dbc14a..373d6264d58589e9ed2db4c618d377d48d71a0a9 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Task.cs
+// TaskExceptionSlot.cs
 //
 // Authors:
 //    Marek Safar  <marek.safar@gmail.com>
@@ -51,8 +51,14 @@ namespace System.Threading.Tasks
                ~TaskExceptionSlot ()
                {
                        if (Exception != null && !Observed && !TaskScheduler.FireUnobservedEvent (parent, Exception).Observed) {
-                               parent = null;
+                               // NET 4.5 changed the default exception behavior for unobserved exceptions. Unobserved exceptions still cause
+                               // the UnobservedTaskException event to be raised but the process will not crash by default
+                               //
+                               // .NET allows to configure this using config element ThrowUnobservedTaskExceptions
+                               //
+#if !NET_4_5
                                throw Exception;
+#endif
                        }
                }
        }