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;
// record to the metadata database
InstancesForm instancesForm = new InstancesForm();
try
using (InstancesForm instancesForm = new InstancesForm())
{
instancesForm.GetDatabaseInstance().Insert(new Dictionary<string, object>
try
{
["InstanceId"] = instanceId,
["FirstDeployTime"] = now
}, out _);
instancesForm.GetDatabaseInstance().Insert(new Dictionary<string, object>
{
["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