From 2e92255a3c0d7a7495e09bfe860220c41e3f2ce8 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Thu, 20 Nov 2025 17:31:50 +0900 Subject: [PATCH] Use 'using' statement for InstancesForm disposal Replaces manual disposal of InstancesForm with a 'using' statement to ensure proper resource management and exception safety when recording to the metadata database. --- WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs index a9a9c56..bad2a37 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs @@ -90,20 +90,21 @@ namespace WelsonJS.Launcher DateTime now = DateTime.Now; // record to the metadata database - InstancesForm instancesForm = new InstancesForm(); - try + using (InstancesForm instancesForm = new InstancesForm()) { - instancesForm.GetDatabaseInstance().Insert(new Dictionary + try { - ["InstanceId"] = instanceId, - ["FirstDeployTime"] = now - }, out _); + instancesForm.GetDatabaseInstance().Insert(new Dictionary + { + ["InstanceId"] = instanceId, + ["FirstDeployTime"] = now + }, out _); + } + catch (Exception ex) + { + _logger.Error($"Failed to record first deploy time: {ex.Message}"); + } } - catch (Exception ex) - { - _logger.Error($"Failed to record first deploy time: {ex.Message}"); - } - instancesForm.Dispose(); // record to the instance directory try