C# Класс 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.
Наследование: SIL.Utils.FwDisposableBase
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
DisposeManagedResources ( ) : void

Disposes managed resources.

Описание методов

DisposeManagedResources() защищенный метод

Disposes managed resources.
protected DisposeManagedResources ( ) : void
Результат void

GlobalMutex() публичный метод

Initializes a new instance of the GlobalMutex class.
public GlobalMutex ( string name ) : System
name string
Результат System

Initialize() публичный метод

Initializes this mutex.
public Initialize ( ) : bool
Результат bool

InitializeAndLock() публичный метод

Initializes and locks this mutex. This is an atomic operation on Windows, but not Linux.
public InitializeAndLock ( ) : IDisposable
Результат IDisposable

InitializeAndLock() публичный метод

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
Результат IDisposable

Lock() публичный метод

Locks this mutex.
public Lock ( ) : IDisposable
Результат IDisposable

Unlink() публичный метод

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
Результат bool