ILockApiLock Method |
Namespace: Casewhere.Runtime.DSL.Api
void Lock( string lockId, TimeSpan waitingTime, TimeSpan expiredTime )
var 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); // check if (dataObject.Get<int>("Count") > 0) { // lock lockApi.Lock(lockId, waitingTime, expiredTime); // check dataObject = dataApi.Load(objectId); if (dataObject.Get<int>("Count") > 0) { // do lock logic // release lockApi.Release(lockId); } }