Class TemporaryDbLock
Locking class for implementing concurrency of relatively quick (within one request) run time operations. using (var lock = new TemporaryDbLock(tableNumber, key) { if (!lock.IsValid) return; // You didn't get the lock, so return or continue. You must check if you actually got the lock.
// you have the lock, do stuff... lock.Update() // Will keep the lock alive, not timing out, while you work. .... }
Implements
Inherited Members
Namespace: SuperOffice.CRM
Assembly: SoDataBase.dll
Syntax
public sealed class TemporaryDbLock : IAsyncDisposable
Properties
IsLocked
Locking class for implementing concurrency of relatively quick (within one request) run time operations. using (var lock = new TemporaryDbLock(tableNumber, key) { if (!lock.IsValid) return; // You didn't get the lock, so return or continue. You must check if you actually got the lock.
// you have the lock, do stuff... lock.Update() // Will keep the lock alive, not timing out, while you work. .... }
Declaration
public bool IsLocked { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
CreateAsync(int, int, int, CancellationToken)
Locking class for implementing concurrency of relatively quick (within one request) run time operations. using (var lock = new TemporaryDbLock(tableNumber, key) { if (!lock.IsValid) return; // You didn't get the lock, so return or continue. You must check if you actually got the lock.
// you have the lock, do stuff... lock.Update() // Will keep the lock alive, not timing out, while you work. .... }
Declaration
public static Task<TemporaryDbLock> CreateAsync(int tableNumber, int key, int seconds = 600, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | tableNumber | |
int | key | |
int | seconds | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<TemporaryDbLock> |
DisposeAsync()
Locking class for implementing concurrency of relatively quick (within one request) run time operations. using (var lock = new TemporaryDbLock(tableNumber, key) { if (!lock.IsValid) return; // You didn't get the lock, so return or continue. You must check if you actually got the lock.
// you have the lock, do stuff... lock.Update() // Will keep the lock alive, not timing out, while you work. .... }
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
FlushAllTempDbLocksAsync(CancellationToken)
Locking class for implementing concurrency of relatively quick (within one request) run time operations. using (var lock = new TemporaryDbLock(tableNumber, key) { if (!lock.IsValid) return; // You didn't get the lock, so return or continue. You must check if you actually got the lock.
// you have the lock, do stuff... lock.Update() // Will keep the lock alive, not timing out, while you work. .... }
Declaration
public static Task<int> FlushAllTempDbLocksAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<int> |
TryUpdateAsync()
Locking class for implementing concurrency of relatively quick (within one request) run time operations. using (var lock = new TemporaryDbLock(tableNumber, key) { if (!lock.IsValid) return; // You didn't get the lock, so return or continue. You must check if you actually got the lock.
// you have the lock, do stuff... lock.Update() // Will keep the lock alive, not timing out, while you work. .... }
Declaration
public Task<bool> TryUpdateAsync()
Returns
Type | Description |
---|---|
Task<bool> |
UpdateAsync()
Locking class for implementing concurrency of relatively quick (within one request) run time operations. using (var lock = new TemporaryDbLock(tableNumber, key) { if (!lock.IsValid) return; // You didn't get the lock, so return or continue. You must check if you actually got the lock.
// you have the lock, do stuff... lock.Update() // Will keep the lock alive, not timing out, while you work. .... }
Declaration
public Task UpdateAsync()
Returns
Type | Description |
---|---|
Task |