Esempio n. 1
0
 public AsyncLock ObtainLock(String filePath)
 {
     lock ( syncLock )
     {
         LockWithCounter lockWithCounter = null;
         if (!ongoingOperations.TryGetValue(filePath, out lockWithCounter))
         {
             lockWithCounter = new LockWithCounter();
             ongoingOperations.Add(filePath, lockWithCounter);
         }
         lockWithCounter.counter++;
         return(lockWithCounter.asyncLock);
     }
 }
Esempio n. 2
0
        public void ReleaseLock(string filePath)
        {
            lock ( syncLock )
            {
                LockWithCounter lockWithCounter = null;
                if (ongoingOperations.TryGetValue(filePath, out lockWithCounter))
                {
                    lockWithCounter.counter--;

                    if (lockWithCounter.counter <= 0)
                    {
                        ongoingOperations.Remove(filePath);
                    }
                }
            }
        }