public static bool Create(bool initiallyOwned, out MutexHandle handle) { unsafe { fixed(MutexHandle *handlePtr = &handle) { return(CreateImpl(initiallyOwned, handlePtr)); } } }
public static void Dispose(MutexHandle handle) { Tracing.Log(Tracing.Debug, "MutexHandle.Dispose(id={0:x8})", handle.id); // // Releasing the handle will allow the mutex to be // garbage-collected. // Thread.CurrentProcess.ReleaseHandle(handle.id); }
public static bool IsOwnedByCurrentThread(MutexHandle handle) { Tracing.Log(Tracing.Debug, "MutexHandle.IsOwnedByCurrentThread(id={0:x8})", handle.id); // // Convert the handle to a mutex; check the ownership of the mutex. // Mutex mutex = HandleTable.GetHandle(handle.id) as Mutex; return(mutex.IsOwnedByCurrentThread()); }
public static void Release(MutexHandle handle) { Tracing.Log(Tracing.Debug, "MutexHandle.Release(id={0:x8})", handle.id); // // Convert the handle to a mutex; release the mutex. // Mutex mutex = HandleTable.GetHandle(handle.id) as Mutex; mutex.ReleaseMutex(); }
public static bool Create(bool initiallyOwned, out MutexHandle handle) { // // Create a new mutex, and a handle in the current process // to hold it. // // Note: the mutex is created as a non-kernel object so that // SIP threads owning mutex can be forcibly stopped // handle = new MutexHandle(Thread.CurrentProcess.AllocateHandle( new Mutex(initiallyOwned, false))); Tracing.Log(Tracing.Debug, "MutexHandle.Create(, out id={0:x8})", handle.id); return(true); }
public static extern bool IsOwnedByCurrentThread(MutexHandle handle);
public static extern void Release(MutexHandle handle);
public static extern void Dispose(MutexHandle handle);