fix: 修复软件未完全退出问题
This commit is contained in:
14
MainForm.cs
14
MainForm.cs
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user