+#if !NET_2_1
+ [MonoTODO ("Use MutexSecurity in CreateMutex_internal")]
+ [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.MayFail)]
+ public Mutex (bool initiallyOwned, string name, out bool createdNew, MutexSecurity mutexSecurity)
+ {
+ Handle = CreateMutex_internal (initiallyOwned, name, out createdNew);
+ }
+
+ public MutexSecurity GetAccessControl ()
+ {
+ return new MutexSecurity (SafeWaitHandle,
+ AccessControlSections.Owner |
+ AccessControlSections.Group |
+ AccessControlSections.Access);
+ }
+
+ public static Mutex OpenExisting (string name)
+ {
+ return(OpenExisting (name, MutexRights.Synchronize |
+ MutexRights.Modify));
+ }
+
+ public static Mutex OpenExisting (string name,
+ MutexRights rights)
+ {
+ if (name == null) {
+ throw new ArgumentNullException ("name");
+ }
+ if ((name.Length == 0) ||
+ (name.Length > 260)) {
+ throw new ArgumentException ("name", Locale.GetText ("Invalid length [1-260]."));
+ }
+
+ MonoIOError error;
+ IntPtr handle = OpenMutex_internal (name, rights,
+ out error);
+ if (handle == (IntPtr)null) {
+ if (error == MonoIOError.ERROR_FILE_NOT_FOUND) {
+ throw new WaitHandleCannotBeOpenedException (Locale.GetText ("Named Mutex handle does not exist: ") + name);
+ } else if (error == MonoIOError.ERROR_ACCESS_DENIED) {
+ throw new UnauthorizedAccessException ();
+ } else {
+ throw new IOException (Locale.GetText ("Win32 IO error: ") + error.ToString ());
+ }
+ }
+
+ return(new Mutex (handle));
+ }
+#endif
+