[corlib] Fixes security tests failures
[mono.git] / mcs / class / corlib / System.Threading / WaitHandle.cs
index 9d20cd09cc93d5aca58ed0fd1eccf326dd2398de..5558efad52f46159fe85716d319e60902ec26eaa 100644 (file)
@@ -40,12 +40,9 @@ using System.Runtime.ConstrainedExecution;
 namespace System.Threading
 {
        [ComVisible (true)]
+       [StructLayout (LayoutKind.Sequential)]
        public abstract class WaitHandle
-#if MOONLIGHT
-               : IDisposable
-#else
                : MarshalByRefObject, IDisposable
-#endif
        {
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private static extern bool WaitAll_internal(WaitHandle[] handles, int ms, bool exitContext);
@@ -242,11 +239,7 @@ namespace System.Threading
                        Dispose(true);
                }
 
-#if NET_4_0 || MOBILE || MOONLIGHT
                public void Dispose ()
-#else          
-               void IDisposable.Dispose ()
-#endif
                {
                        Close ();
                }
@@ -374,17 +367,17 @@ namespace System.Threading
                        bool release = false;
                        try {
                                if (exitContext) {
-#if MONOTOUCH
-                                       throw new NotSupportedException ("exitContext == true is not supported");
-#else
+#if !MONOTOUCH
                                        SynchronizationAttribute.ExitContext ();
 #endif
                                }
                                safe_wait_handle.DangerousAddRef (ref release);
                                return (WaitOne_internal(safe_wait_handle.DangerousGetHandle (), millisecondsTimeout, exitContext));
                        } finally {
+#if !MONOTOUCH
                                if (exitContext)
                                        SynchronizationAttribute.EnterContext ();
+#endif
                                if (release)
                                        safe_wait_handle.DangerousRelease ();
                        }
@@ -410,9 +403,7 @@ namespace System.Threading
                        bool release = false;
                        try {
                                if (exitContext) {
-#if MONOTOUCH
-                                       throw new NotSupportedException ("exitContext == true is not supported");
-#else
+#if !MONOTOUCH
                                        SynchronizationAttribute.ExitContext ();
 #endif
                                }
@@ -420,8 +411,10 @@ namespace System.Threading
                                return (WaitOne_internal(safe_wait_handle.DangerousGetHandle (), (int) ms, exitContext));
                        }
                        finally {
+#if !MONOTOUCH
                                if (exitContext)
                                        SynchronizationAttribute.EnterContext ();
+#endif
                                if (release)
                                        safe_wait_handle.DangerousRelease ();
                        }