Example #1
0
        public static void ToLock(this ILockManager lockManger, string key, string lockValue, Action action)
        {
            if (!lockManger.LockKey(key, lockValue))
            {
                throw new MikeException("锁超时");
            }

            try
            {
                action();
            }
            catch (Exception ex)
            {
                throw new MikeException(ex.Message);
            }
            finally
            {
                lockManger.UnlockKey(key, lockValue);
            }
        }
Example #2
0
 public IHttpActionResult Lock(LockModel model)
 {
     return(Ok(_lock.LockKey(model.LockKey, model.LockValue)));
 }