コード例 #1
0
        public static void AssertOwnershipCannotBeObtained(string name, CreateMutexFunc createMutexFunc, string additionalMessage = null)
        {
            var msg = "Expected to be unable to obtain ownership, but could.";

            if (!string.IsNullOrEmpty(additionalMessage))
            {
                msg = $"{msg}  {additionalMessage}";
            }

            Assert.IsFalse(CanGrabOwnershipOnDifferentThread(name, createMutexFunc), msg);
        }
コード例 #2
0
 public static bool CanGrabOwnershipOnDifferentThread(string name, CreateMutexFunc createMutexFunc)
 {
     return(RunOnDifferentThread(() =>
     {
         bool owned;
         using (var mutex = createMutexFunc(true, name, out owned))
         {
             //mutex.ReleaseMutex();
             return owned;
         }
     }));
 }