C# Class SIL.Utils.GlobalMutex

This is a cross-platform, global, named mutex that can be used to synchronize access to data across processes. It supports reentrant locking. This is needed because Mono does not support system-wide, named mutexes. Mono does implement the Mutex class, but even when using the constructors with names, it only works within a single process.
Inheritance: SIL.Utils.FwDisposableBase
Mostra file Open project: sillsdev/FieldWorks Class Usage Examples

Public Methods

Method Description
GlobalMutex ( string name ) : System

Initializes a new instance of the GlobalMutex class.

Initialize ( ) : bool

Initializes this mutex.

InitializeAndLock ( ) : IDisposable

Initializes and locks this mutex. This is an atomic operation on Windows, but not Linux.

InitializeAndLock ( bool &createdNew ) : IDisposable

Initializes and locks this mutex. On Windows, this is an atomic operation, so the "createdNew" variable is guaranteed to return a correct value. On Linux, this is not an atomic operation, so "createdNew" is guaranteed to be correct only if it returns true.

Lock ( ) : IDisposable

Locks this mutex.

Unlink ( ) : bool

Unlinks or removes the mutex from the system. This only has an effect on Linux. Windows will automatically unlink the mutex. This can be called while the mutex is locked.

Protected Methods

Method Description
DisposeManagedResources ( ) : void

Disposes managed resources.

Method Details

DisposeManagedResources() protected method

Disposes managed resources.
protected DisposeManagedResources ( ) : void
return void

GlobalMutex() public method

Initializes a new instance of the GlobalMutex class.
public GlobalMutex ( string name ) : System
name string
return System

Initialize() public method

Initializes this mutex.
public Initialize ( ) : bool
return bool

InitializeAndLock() public method

Initializes and locks this mutex. This is an atomic operation on Windows, but not Linux.
public InitializeAndLock ( ) : IDisposable
return IDisposable

InitializeAndLock() public method

Initializes and locks this mutex. On Windows, this is an atomic operation, so the "createdNew" variable is guaranteed to return a correct value. On Linux, this is not an atomic operation, so "createdNew" is guaranteed to be correct only if it returns true.
public InitializeAndLock ( bool &createdNew ) : IDisposable
createdNew bool
return IDisposable

Lock() public method

Locks this mutex.
public Lock ( ) : IDisposable
return IDisposable

Unlink() public method

Unlinks or removes the mutex from the system. This only has an effect on Linux. Windows will automatically unlink the mutex. This can be called while the mutex is locked.
public Unlink ( ) : bool
return bool