New error message.
[mono.git] / mcs / class / corlib / System.Threading / Mutex.cs
index 423b59d926a7acaa423c1561a07e08cd822f7291..9ada0d973f149a7220ee19dc343286f723bc3f59 100644 (file)
@@ -35,10 +35,14 @@ using System.Security.Permissions;
 using System.Runtime.ConstrainedExecution;
 using System.Security.AccessControl;
 using System.IO;
+using System.Runtime.InteropServices;
 #endif
 
 namespace System.Threading
 {
+#if NET_2_0
+       [ComVisible (true)]
+#endif
        public sealed class Mutex : WaitHandle 
        {
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -48,7 +52,7 @@ namespace System.Threading
                                                         out bool created);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private static extern void ReleaseMutex_internal(IntPtr handle);
+               private static extern bool ReleaseMutex_internal(IntPtr handle);
 
 #if NET_2_0
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
@@ -106,6 +110,11 @@ namespace System.Threading
                        Handle = CreateMutex_internal (initiallyOwned, name, out createdNew);
                }
 
+               public MutexSecurity GetAccessControl ()
+               {
+                       throw new NotImplementedException ();
+               }
+
                public static Mutex OpenExisting (string name)
                {
                        return(OpenExisting (name, MutexRights.Synchronize |
@@ -144,7 +153,17 @@ namespace System.Threading
                [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
 #endif 
                public void ReleaseMutex() {
-                       ReleaseMutex_internal(Handle);
+                       bool success = ReleaseMutex_internal(Handle);
+                       if (!success) {
+                               throw new ApplicationException ("Mutex is not owned");
+                       }
                }
+
+#if NET_2_0
+               public void SetAccessControl (MutexSecurity mutexSecurity)
+               {
+                       throw new NotImplementedException ();
+               }
+#endif
        }
 }