コード例 #1
0
 /// <summary>
 /// 获取一个锁(需要自己释放)
 /// </summary>
 /// <param name="lock">业务锁</param>
 /// <param name="key">锁定标识</param>
 /// <param name="expiration">锁定时间间隔</param>
 /// <returns>true:成功锁定; false:之前已被锁定</returns>
 public static async Task <bool> LockTakAsync(this ILock @lock, string key, TimeSpan expiration) =>
 await @lock.LockTakeAsync(key, "1", expiration);