DIspose添加
This commit is contained in:
@@ -79,20 +79,34 @@ namespace MainModule.ViewModels
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// 1. 如果 TestStatus 为空,说明还没走到 OnNavigatedTo 赋值,直接释放 scope 即可
|
||||
if (string.IsNullOrEmpty(TestStatus))
|
||||
{
|
||||
_scope?.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 2. 显式释放硬件资源(防止端口占用/死锁)
|
||||
if (_deviceManager is IDisposable disposableDevice)
|
||||
{
|
||||
disposableDevice.Dispose();
|
||||
}
|
||||
(CommandTreeVM as IDisposable)?.Dispose();
|
||||
(StepsManagerVM as IDisposable)?.Dispose();
|
||||
(SingleStepEditVM as IDisposable)?.Dispose();
|
||||
(LogAreaVM as IDisposable)?.Dispose();
|
||||
(ParametersManagerVM as IDisposable)?.Dispose();
|
||||
|
||||
_globalInfo.ContextDic?.Remove(TestStatus);
|
||||
_globalInfo.StepRunningDic?.Remove(TestStatus);
|
||||
_globalInfo.ConfigDic?.Remove(TestStatus);
|
||||
_globalInfo.ScopeDic?.Remove(TestStatus);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LoggerHelper.ErrorWithNotify($"卸载机台 [{TestStatus}] 全局引用失败: {ex.Message}");
|
||||
Logger.LoggerHelper.ErrorWithNotify($"卸载机台 [{TestStatus}] 全局引用或资源失败: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user