This commit is contained in:
GukSang.Jin
2026-03-16 19:10:33 +08:00
parent 34083df6de
commit 88a65233a7
26 changed files with 839 additions and 235 deletions

View File

@@ -28,6 +28,12 @@ namespace 自救器呼吸器综合检验仪
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
if (AppShutdownCoordinator.ShouldSuppressDuringShutdown(e.Exception))
{
e.Handled = true;
return;
}
LogError(e.Exception, "UI线程异常");
e.Handled = true; // 标记为已处理,避免崩溃(仅用于调试)
}
@@ -49,6 +55,11 @@ namespace 自救器呼吸器综合检验仪
string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "error.log");
string logContent = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {type}\n{ex.ToString()}\n\n";
File.AppendAllText(logPath, logContent);
if (AppShutdownCoordinator.IsShutdownInProgress)
{
return;
}
MessageBox.Show($"发生错误,详情已记录到 {logPath}", "错误");
}