mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-29 19:03:42 +00:00
Improve resource server initialization and mutex handling
Adds a null check for the resource server after initialization and logs an error if it fails. Changes duplicate launcher instance log from error to info, and wraps mutex release in a try-catch to prevent exceptions if not owned.
This commit is contained in:
parent
f3db44d8e3
commit
e9d475ba4c
|
|
@ -177,6 +177,12 @@ namespace WelsonJS.Launcher
|
||||||
{
|
{
|
||||||
Program.InitializeResourceServer();
|
Program.InitializeResourceServer();
|
||||||
|
|
||||||
|
if (Program._resourceServer == null)
|
||||||
|
{
|
||||||
|
_logger.Error("Resource server failed to initialize.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Program._resourceServer.IsRunning())
|
if (!Program._resourceServer.IsRunning())
|
||||||
{
|
{
|
||||||
Program._resourceServer.Start(false);
|
Program._resourceServer.Start(false);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace WelsonJS.Launcher
|
||||||
_mutex = new Mutex(true, "WelsonJS.Launcher", out bool createdNew);
|
_mutex = new Mutex(true, "WelsonJS.Launcher", out bool createdNew);
|
||||||
if (!createdNew)
|
if (!createdNew)
|
||||||
{
|
{
|
||||||
_logger.Error("WelsonJS Launcher already running.");
|
_logger.Info("WelsonJS Launcher already running.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +42,9 @@ namespace WelsonJS.Launcher
|
||||||
Application.Run(new MainForm(_logger));
|
Application.Run(new MainForm(_logger));
|
||||||
|
|
||||||
// destory the mutex
|
// destory the mutex
|
||||||
|
try {
|
||||||
_mutex.ReleaseMutex();
|
_mutex.ReleaseMutex();
|
||||||
|
} catch { /* ignore if not owned */ }
|
||||||
_mutex.Dispose();
|
_mutex.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user