精确优化程序关闭问题
This commit is contained in:
@@ -41,6 +41,12 @@ namespace 全自动水压检测仪
|
||||
|
||||
private void UpdateTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// 检查窗体状态
|
||||
if (this.IsDisposed || !this.IsHandleCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
UpdateStatusDisplay();
|
||||
@@ -111,8 +117,20 @@ namespace 全自动水压检测仪
|
||||
|
||||
private void StatusSettingsForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
_updateTimer?.Stop();
|
||||
_updateTimer?.Dispose();
|
||||
try
|
||||
{
|
||||
if (_updateTimer != null)
|
||||
{
|
||||
_updateTimer.Stop();
|
||||
_updateTimer.Tick -= UpdateTimer_Tick;
|
||||
_updateTimer.Dispose();
|
||||
_updateTimer = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"释放定时器资源失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void uiButton_Close_Click(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user