fix: 修复软件未完全退出问题

This commit is contained in:
2026-01-19 10:08:07 +08:00
parent fe47293da5
commit 0ab770d464
2 changed files with 16 additions and 13 deletions

View File

@@ -130,8 +130,6 @@ namespace TimerApp
_monitor.Start();
SystemEvents.PowerModeChanged += OnPowerModeChanged;
// Set tray icon
try
{
@@ -553,7 +551,6 @@ namespace TimerApp
}
else
{
SystemEvents.PowerModeChanged -= OnPowerModeChanged;
notifyIcon1.Visible = false;
notifyIcon1.Dispose();
}
@@ -599,6 +596,7 @@ namespace TimerApp
notifyIcon1.Visible = false;
notifyIcon1.Dispose();
Application.Exit();
Environment.Exit(0);
}
private void pnlTitle_MouseDown(object sender, MouseEventArgs e)
@@ -619,15 +617,5 @@ namespace TimerApp
{
this.WindowState = FormWindowState.Minimized;
}
private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Resume)
{
// 系统唤醒时,强制重置媒体播放检测状态,
// 避免因检测线程挂起导致一直误报“正在播放”而无法进入工作状态。
NativeMethods.InvalidateMediaCache();
}
}
}
}