Ejemplo n.º 1
0
 internal MutexTryCodeHelper(bool initiallyOwned, Mutex.MutexCleanupInfo cleanupInfo, string name, Win32Native.SECURITY_ATTRIBUTES secAttrs, Mutex mutex)
 {
     this.m_initiallyOwned = initiallyOwned;
     this.m_cleanupInfo    = cleanupInfo;
     this.m_name           = name;
     this.m_secAttrs       = secAttrs;
     this.m_mutex          = mutex;
 }
Ejemplo n.º 2
0
 internal void CreateMutexWithGuaranteedCleanup(bool initiallyOwned, string name, out bool createdNew, Win32Native.SECURITY_ATTRIBUTES secAttrs)
 {
     RuntimeHelpers.CleanupCode backoutCode        = new RuntimeHelpers.CleanupCode(this.MutexCleanupCode);
     Mutex.MutexCleanupInfo     cleanupInfo        = new Mutex.MutexCleanupInfo((SafeWaitHandle)null, false);
     Mutex.MutexTryCodeHelper   mutexTryCodeHelper = new Mutex.MutexTryCodeHelper(initiallyOwned, cleanupInfo, name, secAttrs, this);
     RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(new RuntimeHelpers.TryCode(mutexTryCodeHelper.MutexTryCode), backoutCode, (object)cleanupInfo);
     createdNew = mutexTryCodeHelper.m_newMutex;
 }
Ejemplo n.º 3
0
 private void MutexCleanupCode(object userData, bool exceptionThrown)
 {
     Mutex.MutexCleanupInfo mutexCleanupInfo = (Mutex.MutexCleanupInfo)userData;
     if (!this.hasThreadAffinity)
     {
         if (mutexCleanupInfo.mutexHandle != null && !mutexCleanupInfo.mutexHandle.IsInvalid)
         {
             if (mutexCleanupInfo.inCriticalRegion)
             {
                 Win32Native.ReleaseMutex(mutexCleanupInfo.mutexHandle);
             }
             mutexCleanupInfo.mutexHandle.Dispose();
         }
         if (mutexCleanupInfo.inCriticalRegion)
         {
             Thread.EndCriticalRegion();
             Thread.EndThreadAffinity();
         }
     }
 }
 internal MutexTryCodeHelper(bool initiallyOwned, Mutex.MutexCleanupInfo cleanupInfo, string name, Win32Native.SECURITY_ATTRIBUTES secAttrs, Mutex mutex)
 {
     this.m_initiallyOwned = initiallyOwned;
     this.m_cleanupInfo = cleanupInfo;
     this.m_name = name;
     this.m_secAttrs = secAttrs;
     this.m_mutex = mutex;
 }