diff --git a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs index 81f08f5..21d2359 100644 --- a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs +++ b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs @@ -1512,9 +1512,56 @@ namespace JoyD.Windows.CS.Toprie imageBox.Image = null; } - // 注意:根据要求,在程序退出前不需要对LastImage、InfoImage和imagebuffer执行Dispose和设置为null - // 保留注释以表明设计意图 - // 这些资源将由垃圾回收器自动管理 + // 释放图像缓冲区资源 + if (_imageBuffer != null) + { + try + { + _imageBuffer.Dispose(); + _imageBuffer = null; + Console.WriteLine("图像缓冲区资源已释放"); + } + catch (Exception ex) + { + Console.WriteLine($"清理ImageBuffer资源异常: {ex.Message}"); + } + } + + // 释放LastImage资源 + lock (_lastImageLock) + { + if (_lastImage != null) + { + try + { + _lastImage.Dispose(); + _lastImage = null; + Console.WriteLine("LastImage资源已释放"); + } + catch (Exception ex) + { + Console.WriteLine($"清理LastImage资源异常: {ex.Message}"); + } + } + } + + // 释放InfoImage资源 + lock (_infoImageLock) + { + if (_infoImage != null) + { + try + { + _infoImage.Dispose(); + _infoImage = null; + Console.WriteLine("InfoImage资源已释放"); + } + catch (Exception ex) + { + Console.WriteLine($"清理InfoImage资源异常: {ex.Message}"); + } + } + } // 释放组件资源 if (components != null)