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.
This commit is contained in:
Namhyeon Go 2025-11-20 17:31:50 +09:00
parent 4bd05fd2a2
commit 2e92255a3c

View File

@ -90,20 +90,21 @@ namespace WelsonJS.Launcher
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
// record to the metadata database // record to the metadata database
InstancesForm instancesForm = new InstancesForm(); using (InstancesForm instancesForm = new InstancesForm())
try
{ {
instancesForm.GetDatabaseInstance().Insert(new Dictionary<string, object> try
{ {
["InstanceId"] = instanceId, instancesForm.GetDatabaseInstance().Insert(new Dictionary<string, object>
["FirstDeployTime"] = now {
}, out _); ["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 // record to the instance directory
try try