void Lock()
        {
            if (currentAppLock != null)
            {
                // lock already taken
                return;
            }

            var lockFile = new FileInfo(Path.Combine(dataDir.FullName, AppPaths.LockFileRelativePath));

            if (!lockFile.Exists)
            {
                try
                {
                    lockFile.Create().Dispose();
                }
                catch (IOException)
                {
                    // wait a moment to ensure file system is updated
                    Thread.Sleep(100);
                    lockFile.Refresh();
                    if (lockFile.Exists)
                    {
                        // ignore, something else created the lock file
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            currentAppLock = FileLock.EnterWait(lockFile.FullName, TimeSpan.FromSeconds(15));
        }
            public void WritesProcessInfo()
            {
                var lockFilePath = Path.Combine(TempDir.AbsolutePath, LockFileName);

                File.Create(lockFilePath).Dispose();

                FileLock = FileLock.EnterWait(lockFilePath, TimeSpan.Zero);

                AssertHasProcessInfo(lockFilePath);
            }
            public void LocksAndReleases()
            {
                var lockFilePath = Path.Combine(TempDir.AbsolutePath, LockFileName);

                File.Create(lockFilePath).Dispose();

                AssertNoLock(lockFilePath);

                FileLock = FileLock.EnterWait(lockFilePath, TimeSpan.Zero);

                AssertLockFails(lockFilePath);

                FileLock.Dispose();

                AssertNoLock(lockFilePath);
            }