From 37af748e350f8a8fc63a17196756cc6bab2d80f0 Mon Sep 17 00:00:00 2001 From: Damon Lewis Date: Mon, 3 Feb 2025 11:58:15 +1100 Subject: [PATCH] Review Feedback Use "Directory" instead of "Folder" in variable name. --- SingleAppInstance/SingleAppInstance.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SingleAppInstance/SingleAppInstance.cs b/SingleAppInstance/SingleAppInstance.cs index 576fb5d..b976d6c 100644 --- a/SingleAppInstance/SingleAppInstance.cs +++ b/SingleAppInstance/SingleAppInstance.cs @@ -11,8 +11,8 @@ namespace ktsu.SingleAppInstance; /// public static class SingleAppInstance { - internal static AbsoluteDirectoryPath PidFolderPath { get; } = AppData.Path; - internal static AbsoluteFilePath PidFilePath { get; } = PidFolderPath / $".{nameof(SingleAppInstance)}.pid".As(); + internal static AbsoluteDirectoryPath PidDirectoryPath { get; } = AppData.Path; + internal static AbsoluteFilePath PidFilePath { get; } = PidDirectoryPath / $".{nameof(SingleAppInstance)}.pid".As(); /// /// Exits the application if another instance is already running. @@ -56,7 +56,8 @@ public static bool ShouldLaunch() // in case there was a race and another instance is starting at the same time we // need to check again to see if we won the lock - return !IsAlreadyRunning(); + + return IsAlreadyRunning(); } /// @@ -79,7 +80,7 @@ internal static bool IsAlreadyRunning() if (filePid == currentPid) { //if the pid in the file is the same as the current pid, exit - return false; + return true; } //is the process still running? @@ -110,7 +111,7 @@ internal static bool IsAlreadyRunning() /// internal static void WritePidFile() { - Directory.CreateDirectory(PidFolderPath); + Directory.CreateDirectory(PidDirectoryPath); File.WriteAllText(PidFilePath, Environment.ProcessId.ToString(CultureInfo.InvariantCulture)); } }