Class WorkflowLock
Provides advisory workflow-level locking for exclusive edit access. Locks are held by a specific user and expire after a configurable duration to prevent stale locks from blocking other users indefinitely.
public sealed class WorkflowLock
- Inheritance
-
WorkflowLock
- Inherited Members
Constructors
WorkflowLock(TimeSpan?)
Creates a new workflow lock manager.
public WorkflowLock(TimeSpan? defaultExpiry = null)
Parameters
defaultExpiryTimeSpan?Default lock duration before auto-expiry. Defaults to 30 minutes.
Properties
ActiveLockCount
Number of active (non-expired) locks.
public int ActiveLockCount { get; }
Property Value
Methods
Extend(string, string, TimeSpan)
Extends the expiry of an existing lock. Only the owner can extend.
public bool Extend(string workflowName, string owner, TimeSpan extension)
Parameters
Returns
ForceRelease(string)
Force-releases a lock regardless of owner (admin operation).
public bool ForceRelease(string workflowName)
Parameters
workflowNamestring
Returns
GetLock(string)
Checks if a workflow is currently locked and by whom.
public LockEntry? GetLock(string workflowName)
Parameters
workflowNamestring
Returns
IsLockedBy(string, string)
Checks if the given user holds the lock (or the workflow is unlocked).
public bool IsLockedBy(string workflowName, string owner)
Parameters
Returns
ListActiveLocks()
Lists all active (non-expired) locks.
public IReadOnlyList<LockEntry> ListActiveLocks()
Returns
Release(string, string)
Releases a lock. Only the lock owner can release it.
public bool Release(string workflowName, string owner)
Parameters
Returns
TryAcquire(string, string, TimeSpan?)
Attempts to acquire an exclusive lock on a workflow. Returns true if the lock was acquired, false if held by another user.
public bool TryAcquire(string workflowName, string owner, TimeSpan? expiry = null)