mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-27 10:00:57 +00:00
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:
parent
4bd05fd2a2
commit
2e92255a3c
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user