public virtual bool InterfaceLock() { lock (MutexLock) { if (InterfaceMutex == null) { return(false); } try { if (!InterfaceMutex.WaitOne(0, false)) { return(false); } MutexAquired = true; } #if !WindowsCE catch (AbandonedMutexException) { MutexAquired = true; } #endif catch (Exception) { return(false); } return(true); } }
public virtual bool InterfaceUnlock() { lock (MutexLock) { if (InterfaceMutex == null) { return(true); } if (MutexAquired) { try { InterfaceMutex.ReleaseMutex(); } catch (Exception) { InterfaceMutex.Close(); InterfaceMutex.Dispose(); #if WindowsCE || Android InterfaceMutex = new Mutex(false); #else InterfaceMutex = new Mutex(false, InterfaceMutexName); #endif } MutexAquired = false; } return(true); } }