Execute the lock context
Namespace: Casewhere.Runtime.DSL.ApiAssembly: Casewhere.Runtime (in Casewhere.Runtime.dll) Version: 2.8.5.0
Syntaxvoid Lock(
string lockId,
TimeSpan waitingTime,
TimeSpan expiredTime
)
Parameters
- lockId String
- id of lock context
- waitingTime TimeSpan
- The timeout of waiting for lock context
- expiredTime TimeSpan
- The timeout of lock context
Return Value
lock object of lock context. When LockObject disposed then the lock will be released.
Examplevar lockApi = ctx.Use<ILockApi>();
var objectId = "data object id";
var lockId = "key of lock context";
var expiredTime = TimeSpan.FromSeconds(30);
var waitingTime = TimeSpan.FromSeconds(30);
if (dataObject.Get<int>("Count") > 0)
{
lockApi.Lock(lockId, waitingTime, expiredTime);
dataObject = dataApi.Load(objectId);
if (dataObject.Get<int>("Count") > 0)
{
lockApi.Release(lockId);
}
}
See Also