Appearance
AcquireDatabaseLockAsync Method
Definition
- Namespace:
JASE.Database - Assembly:
JASE.Database.dll
Task<bool> AcquireDatabaseLockAsync(string resource, DatabaseLockMode mode, DatabaseLockOwner owner, TimeSpan? timeout = null, CancellationToken cancellationToken = null)
csharp
Task<bool> AcquireDatabaseLockAsync(string resource, DatabaseLockMode mode, DatabaseLockOwner owner, TimeSpan? timeout = null, CancellationToken cancellationToken = null)Attempts to acquire a database-backed application lock.
Parameters
| Name | Description |
|---|---|
cancellationToken | Token observed before each non-blocking acquisition attempt and while waiting between attempts. A completed acquisition attempt wins over cancellation so its lock can be tracked safely. |
mode | Requested shared or exclusive access. |
owner | Session or transaction lifetime owner. |
resource | Provider-independent lock resource name, limited to 255 characters. |
timeout | Maximum time to wait. A value of waits indefinitely, Zero makes one immediate attempt. |
Returns
when acquired; otherwise after timeout.
Remarks
Transaction ownership requires an active transaction. Session-owned locks retain the underlying database connection and should only be used for short-lived coordination.