示例#1
0
 public AccountLock GetAccountLock(int accountId)
 {
     lock (AccountLocks)
     {
         AccountLock accountLock;
         if (AccountLocks.TryGetValue(accountId, out accountLock))
             accountLock.Counter += 1;
         else
         {
             accountLock = new AccountLock();
             AccountLocks[accountId] = accountLock;
         }
         return accountLock;
     }
 }
示例#2
0
 public void ReleaseAccountLock(int accountId, AccountLock accountLock)
 {
     lock (AccountLocks)
     {
         accountLock.Counter -= 1;
         if (accountLock.Counter <= 0)
             AccountLocks.Remove(accountId);
     }
 }