From 24d6d02a22a3f7c74252b524b4b635f3278a54c3 Mon Sep 17 00:00:00 2001 From: xiaoou Date: Mon, 13 Jul 2026 03:48:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20macOS=20Console.SetOut=20Dispose?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=20=E2=80=94=20=E5=85=88=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E5=86=8DClose=E9=81=BF=E5=85=8DObjectDisposedException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hjha-console/Program.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hjha-console/Program.cs b/hjha-console/Program.cs index 07326640..03c7a0cd 100644 --- a/hjha-console/Program.cs +++ b/hjha-console/Program.cs @@ -62,12 +62,11 @@ namespace hjha_console // 重定向 Console stdout → 本轮 ISMCTS 日志 var ismctsLog = $"{logDir}/round_{r:D5}_ismcts.txt"; var oldOut = Console.Out; - using (var ismctsWriter = new StreamWriter(ismctsLog) { AutoFlush = true }) - { - Console.SetOut(ismctsWriter); - main.Test(""); - } - Console.SetOut(oldOut); + var ismctsWriter = new StreamWriter(ismctsLog) { AutoFlush = true }; + Console.SetOut(ismctsWriter); + main.Test(""); + Console.SetOut(oldOut); // 先恢复再Close (macOS兼容) + ismctsWriter.Close(); // 合并 output.txt + ISMCTS 日志 → 本轮日志 using (var combined = new StreamWriter(logPath, false))