Class LockAcquisition
Provides a set of methods to acquire different types of lock.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public static class LockAcquisition
Methods
| Edit this page View SourceAcquireReadLock(object)
Acquires read lock for the specified object.
Declaration
public static Lock.Holder AcquireReadLock(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be locked. |
Returns
Type | Description |
---|---|
Lock.Holder | The acquired read lock. |
AcquireReadLock(object, TimeSpan)
Acquires read lock for the specified object.
Declaration
public static Lock.Holder AcquireReadLock(object obj, TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be locked. |
TimeSpan | timeout | The amount of time to wait for the lock. |
Returns
Type | Description |
---|---|
Lock.Holder | The acquired read lock. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The lock cannot be acquired during the specified amount of time. |
AcquireUpgradeableReadLock(object)
Acquires upgradeable read lock for the specified object.
Declaration
public static Lock.Holder AcquireUpgradeableReadLock(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be locked. |
Returns
Type | Description |
---|---|
Lock.Holder | The acquired upgradeable read lock. |
AcquireUpgradeableReadLock(object, TimeSpan)
Acquires upgradeable read lock for the specified object.
Declaration
public static Lock.Holder AcquireUpgradeableReadLock(object obj, TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be locked. |
TimeSpan | timeout | The amount of time to wait for the lock. |
Returns
Type | Description |
---|---|
Lock.Holder | The acquired upgradeable read lock. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The lock cannot be acquired during the specified amount of time. |
AcquireWriteLock(object)
Acquires write lock for the specified object.
Declaration
public static Lock.Holder AcquireWriteLock(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be locked. |
Returns
Type | Description |
---|---|
Lock.Holder | The acquired write lock. |
AcquireWriteLock(object, TimeSpan)
Acquires write lock for the specified object.
Declaration
public static Lock.Holder AcquireWriteLock(object obj, TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be locked. |
TimeSpan | timeout | The amount of time to wait for the lock. |
Returns
Type | Description |
---|---|
Lock.Holder | The acquired write lock. |
Exceptions
Type | Condition |
---|---|
TimeoutException | The lock cannot be acquired during the specified amount of time. |