Exemple #1
0
        public bool Release()
        {
            if (_lockStream == null)
            {
                return(false);
            }

            try
            {
                _lockStream.Close();
                File.Delete(_path);

                TraceLock("Lock released");

                try
                {
                    FileSystemHelpers.DeleteIfEmpty(_directory);
                }
                catch
                {
                    // Doesn't matter if this fails, we're just trying to be tidy
                }

                return(true);
            }
            catch
            {
                TraceLock("Lock release failed");
                return(false);
            }
            finally
            {
                Interlocked.Exchange(ref _lockStream, null);
            }
        }