Add the mutex to avoid redundant

This commit is contained in:
Namhyeon Go 2025-03-23 14:43:23 +09:00
parent 54af38b6b6
commit d3135bef8e
2 changed files with 13 additions and 0 deletions

View File

@ -38,6 +38,7 @@ namespace WelsonJS.Launcher
{
e.Cancel = true;
this.Hide();
this.ShowInTaskbar = false;
notifyIcon1.Visible = true;
}
base.OnFormClosing(e);
@ -47,6 +48,7 @@ namespace WelsonJS.Launcher
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
this.Focus();
notifyIcon1.Visible = false;
}

View File

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using WelsonJS.Launcher.Tools;
@ -9,14 +10,24 @@ namespace WelsonJS.Launcher
{
internal static class Program
{
static Mutex mutex;
public static ResourceServer resourceServer;
[STAThread]
static void Main()
{
mutex = new Mutex(true, "WelsonJS.Launcher.Mutex", out bool isMutexNotExists);
if (!isMutexNotExists)
{
MessageBox.Show("WelsonJS Launcher already running.");
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
mutex.ReleaseMutex();
}
public static void RunCommandPrompt(string workingDirectory, string entryFileName, string scriptName, bool isConsoleApplication = false, bool isInteractiveServiceAapplication = false)