Merge pull request #901 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mcs / class / corlib / System.Threading / Monitor.cs
index 7be943f4ed3bdf4ed90b9e82f7b373758c6b8b2d..d6a289e76b5a1754dfb0cc08774185b39a13d62a 100644 (file)
@@ -159,7 +159,13 @@ namespace System.Threading
 
                public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) {
                        try {
-                               if (exitContext) SynchronizationAttribute.ExitContext ();
+                               if (exitContext) {
+#if MONOTOUCH
+                                       throw new NotSupportedException ("exitContext == true is not supported");
+#else
+                                       SynchronizationAttribute.ExitContext ();
+#endif
+                               }
                                return Wait (obj, millisecondsTimeout);
                        }
                        finally {
@@ -169,7 +175,13 @@ namespace System.Threading
 
                public static bool Wait(object obj, TimeSpan timeout, bool exitContext) {
                        try {
-                               if (exitContext) SynchronizationAttribute.ExitContext ();
+                               if (exitContext) {
+#if MONOTOUCH
+                                       throw new NotSupportedException ("exitContext == true is not supported");
+#else
+                                       SynchronizationAttribute.ExitContext ();
+#endif
+                               }
                                return Wait (obj, timeout);
                        }
                        finally {
@@ -177,7 +189,7 @@ namespace System.Threading
                        }
                }
 
-#if NET_4_0 || MOONLIGHT
+#if NET_4_0
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                extern static void try_enter_with_atomic_var (object obj, int millisecondsTimeout, ref bool lockTaken);
 
@@ -212,6 +224,16 @@ namespace System.Threading
                        try_enter_with_atomic_var (obj, millisecondsTimeout, ref lockTaken);
                }               
 
+#endif
+
+#if NET_4_5
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               extern static bool Monitor_test_owner (object obj);
+               
+               public static bool IsEntered (object obj)
+               {
+                       return Monitor_test_owner(obj);
+               }
 #endif
        }
 }