Table of Contents

Class TryLock

Namespace
ArcanaDevelopment.adTempus.Shared
Assembly
ArcanaDevelopment.adTempus.Shared.dll

Replacement for lock operator to provide timeout capabilities.

public class TryLock
Inheritance
object
TryLock

Remarks

Usage: using(var lock=new TryLock(obj,timeout)) { }

Constructors

TryLock(object, int)

Tries to obtain a lock

public TryLock(object obj, int millisecondsTimeout)

Parameters

NameTypeDescription
obj object

The object to lock

millisecondsTimeout int

The maximum number of milliseconds to wait.

Remarks

On return, HasLock indicates whether the lock was obtained.

TryLock(object, int, ILog, string)

Tries to obtain a lock and logs an error message if the lock cannot be obtained

public TryLock(object obj, int millisecondsTimeout, ILog log, string objectName)

Parameters

NameTypeDescription
obj object

The object to lock

millisecondsTimeout int

The maximum number of milliseconds to wait.

log ILog
objectName string

Remarks

On return, HasLock indicates whether the lock was obtained.

TryLock(object, int, ILog, string, Level)

public TryLock(object obj, int millisecondsTimeout, ILog log, string objectName, Level level)

Parameters

NameTypeDescription
obj object
millisecondsTimeout int
log ILog
objectName string
level Level

Fields

DefaultWaitTime

public const int DefaultWaitTime = 5000

Field Value

int

Properties

HasLock

public bool HasLock { get; }

Property Value

bool

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

NameTypeDescription
disposing bool