C# Class Library.DeadlockMonitor

Exibir arquivo Open project: Alliance-Network/Library Class Usage Examples

Public Methods

Method Description
Enter ( object monitor ) : void

Acquires an exclusive lock on the specified object.

Exit ( object monitor ) : void

Releases an exclusive lock on the specified object.

Lock ( object monitor ) : IDisposable

Locks the specified object and returns an IDisposable that can be used to release the lock.

TryEnter ( object monitor ) : bool

Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.

TryEnter ( object monitor, System.TimeSpan timeout ) : bool

Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.

TryEnter ( object monitor, int millisecondsTimeout ) : bool

Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.

Private Methods

Method Description
CreateDeadlockDescription ( CycleComponentNode currentChain, Dictionary locksHeldByThreads ) : string

Creates a textual description of the deadlock.

CreateThreadAndLockTables ( Dictionary &locksHeldByThreads, Dictionary &threadsWaitingOnLocks ) : void

Generates mapping tables based on the data in _monitorStates.

ThrowIfDeadlockDetected ( MonitorState targetMs ) : void

Throws an exception if a deadlock would be caused by the current thread waiting on the specified lock.

Method Details

Enter() public static method

Acquires an exclusive lock on the specified object.
public static Enter ( object monitor ) : void
monitor object The object on which to acquire the monitor lock.
return void

Exit() public static method

Releases an exclusive lock on the specified object.
public static Exit ( object monitor ) : void
monitor object Releases an exclusive lock on the specified object.
return void

Lock() public static method

Locks the specified object and returns an IDisposable that can be used to release the lock.
public static Lock ( object monitor ) : IDisposable
monitor object The object on which to acquire the monitor lock.
return IDisposable

TryEnter() public static method

Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.
public static TryEnter ( object monitor ) : bool
monitor object The object on which to acquire the lock.
return bool

TryEnter() public static method

Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.
public static TryEnter ( object monitor, System.TimeSpan timeout ) : bool
monitor object The object on which to acquire the lock.
timeout System.TimeSpan A TimeSpan representing the amount of time to wait for the lock. A value of -1 millisecond specifies an infinite wait.
return bool

TryEnter() public static method

Attempts, for the specified amount of time, to acquire an exclusive lock on the specified object.
public static TryEnter ( object monitor, int millisecondsTimeout ) : bool
monitor object The object on which to acquire the lock.
millisecondsTimeout int The number of milliseconds to wait for the lock.
return bool