Beispiel #1
0
 public void EnterLock()
 {
     if (!entered)
     {
         fileLock = FileLock.EnterWithCreateWait(Path.Combine(launcherDirPath, LockFileName), TimeSpan.Zero);
         entered  = true;
     }
 }
            public void WritesProcessInfo()
            {
                var lockFilePath = Path.Combine(TempDir.AbsolutePath, LockFileName);

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

                AssertHasProcessInfo(lockFilePath);
            }
Beispiel #3
0
        public FlatFilesDataStorage(string rootPath)
        {
            if (rootPath == null)
            {
                throw new ArgumentNullException(nameof(rootPath));
            }
            this.rootPath = rootPath;

            fileLock = FileLock.EnterWithCreateWait(Path.Combine(rootPath, "dir.lock"), TimeSpan.FromSeconds(15));
        }
            public void ReleasesOnFinalization()
            {
                var lockFilePath = Path.Combine(TempDir.AbsolutePath, LockFileName);

                FileLock = FileLock.EnterWithCreateWait(lockFilePath, TimeSpan.Zero);
                AssertLockFails(lockFilePath);
                FileLock = null;
                GC.Collect(3, GCCollectionMode.Forced, true);
                GC.WaitForPendingFinalizers();
                GC.Collect(3, GCCollectionMode.Forced, true);
                AssertNoLock(lockFilePath);
            }
            public void LocksAndReleases()
            {
                var lockFilePath = Path.Combine(TempDir.AbsolutePath, LockFileName);

                AssertNoFile(lockFilePath);

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

                AssertLockFails(lockFilePath);

                FileLock.Dispose();

                AssertNoLock(lockFilePath);
            }
        public SqLiteDataStorage(string rootPath)
        {
            if (rootPath == null)
            {
                throw new ArgumentNullException(nameof(rootPath));
            }

            if (!Directory.Exists(rootPath))
            {
                Directory.CreateDirectory(rootPath);
            }

            fileLock = FileLock.EnterWithCreateWait(Path.Combine(rootPath, "dir.lock"), TimeSpan.FromSeconds(15));

            databasePath = Path.Combine(rootPath, "database.sqlite");

            UpdateSchema();
            ImportFromObsoleteFlatFiles(rootPath);
        }