In dotnet core how can I ensure only one copy of my application is running?
问题 In the past I have done something like this private static bool AlreadyRunning() { var processes = Process.GetProcesses(); var currentProc = Process.GetCurrentProcess(); logger.Info($"Current proccess: {currentProc.ProcessName}"); foreach (var process in processes) { if (currentProc.ProcessName == process.ProcessName && currentProc.Id != process.Id) { logger.Info($"Another instance of this process is already running: {process.Id}"); return true; } } return false; } Which has worked well. In