Update ServiceMain.cs
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run

This commit is contained in:
Namhyeon Go 2024-07-22 20:36:34 +09:00
parent d758957d68
commit 360d37cd36

View File

@ -97,7 +97,7 @@ namespace WelsonJS.Service
} }
catch (Exception ex) catch (Exception ex)
{ {
Log("Exception: " + ex.Message); Log("Exception when start: " + ex.Message);
} }
} }
else else
@ -121,11 +121,14 @@ namespace WelsonJS.Service
try try
{ {
InvokeScriptMethod("initializeService", scriptName, "stop"); InvokeScriptMethod("initializeService", scriptName, "stop");
if (scriptControl != null)
{
scriptControl.Reset(); scriptControl.Reset();
} }
}
catch (Exception ex) catch (Exception ex)
{ {
Log("Exception: " + ex.Message); Log("Exception when stop: " + ex.Message);
} }
scriptControl = null; scriptControl = null;
@ -140,14 +143,22 @@ namespace WelsonJS.Service
} }
catch (Exception ex) catch (Exception ex)
{ {
Log("Exception: " + ex.Message); Log("Exception when elapsed time: " + ex.Message);
} }
} }
private string InvokeScriptMethod(string methodName, params object[] parameters) private string InvokeScriptMethod(string methodName, params object[] parameters)
{
if (scriptControl != null)
{ {
return scriptControl.Run(methodName, parameters).ToString(); return scriptControl.Run(methodName, parameters).ToString();
} }
else
{
Log("InvokeScriptMethod Ignored: " + methodName);
return null;
}
}
private void Log(string message) private void Log(string message)
{ {