TryLockAndGetFenceAsync Method
TryLockAndGetFenceAsync(LockContext, TimeSpan)
Tries to acquire the lock and return the fencing token assigned to the specified lockContext
context for this lock acquisition.
Declaration
Task<long> TryLockAndGetFenceAsync(LockContext lockContext, TimeSpan timeout)
Parameters
LockContext | lockContext | The LockContext. |
TimeSpan | timeout | The maximum time to wait for the lock. |
Returns
Task<long> | The fencing token if the lock was acquired; otherwise InvalidFence. |
Remarks
If the lock is available or already held by the current specified lockContext
at the time of invocation and the acquisition limit is not exceeded, the method immediately returns
the fencing token assigned to this acquisition. If the lock is not immediately available, the method
immediately returns InvalidFence representing a failed lock attempt.
TryLockAndGetFenceAsync(LockContext)
Tries to acquire the lock and return the fencing token assigned to the specified lockContext
context for this lock acquisition.
Declaration
Task<long> TryLockAndGetFenceAsync(LockContext lockContext)
Parameters
LockContext | lockContext | The LockContext. |
Returns
Task<long> | The fencing token if the lock was acquired; otherwise InvalidFence. |
Remarks
If the lock is available or already held by the current specified lockContext
at the time of invocation and the acquisition limit is not exceeded, the method immediately returns
the fencing token assigned to this acquisition. If the lock is not immediately available, the method
immediately returns InvalidFence representing a failed lock attempt.