Esempio n. 1
0
 public bool IsLocked(string subpath)
 {
     using (_asyncLock.Lock())
     {
         try
         {
             return(IsLockedInternal(subpath));
         }
         catch
         {
             // An error occured while reading the file
             return(true);
         }
     }
 }
Esempio n. 2
0
        public void Release()
        {
            using (_asyncLock.Lock())
            {
                var lockFile = _directory.GetFile(_path);

                if (_released || !lockFile.Exists)
                {
                    return;
                }

                _released = true;

                // Check it has not been granted in the meantime
                var current = _directory.ReadAllText(_path);
                if (current == _content)
                {
                    _directory.TryDeleteFile(_path);
                }
            }
        }