恢复对LastImage、InfoImage和imagebuffer的Dispose操作和设为null
This commit is contained in:
@@ -1512,9 +1512,56 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
imageBox.Image = null;
|
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)
|
if (components != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user