From d9e0be85179a39abe36a4cc23afd91798bcccb82 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 14 六月 2023 14:35:36 +0800
Subject: [PATCH] 解决QGIS出图程序一直处于等待状态,无法正常结束

---
 ExportMap/cs/Tools.cs |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ExportMap/cs/Tools.cs b/ExportMap/cs/Tools.cs
index 2696807..71debf0 100644
--- a/ExportMap/cs/Tools.cs
+++ b/ExportMap/cs/Tools.cs
@@ -159,7 +159,7 @@
         /// </summary>
         /// <param name="cmd">鍛戒护琛�</param>
         /// <returns>鎵ц缁撴灉鎴栧嚭閿欎俊鎭�</returns>
-        public static String ExecCmd(string cmd, bool isPy = false)
+        public static String ExecCmd(string cmd, bool isPy = false, bool isOut = false)
         {
             List<string> list = new List<string>();
             if (isPy)
@@ -171,7 +171,7 @@
             }
             list.Add(cmd);
 
-            string str = ExecCmd(list);
+            string str = ExecCmd(list, isOut);
 
             return str;
         }
@@ -181,7 +181,7 @@
         /// </summary>
         /// <param name="list">鍛戒护闆嗗悎</param>
         /// <returns>鎵ц缁撴灉鎴栧嚭閿欎俊鎭�</returns>
-        public static string ExecCmd(List<string> list)
+        public static string ExecCmd(List<string> list, bool isOut = false)
         {
             string str = null;
             try
@@ -197,7 +197,7 @@
                 p.Start();
 
                 StreamWriter si = p.StandardInput; // 鏍囧噯杈撳叆娴� 
-                //StreamReader so = p.StandardOutput; // 鏍囧噯杈撳嚭娴� 
+                StreamReader so = isOut ? p.StandardOutput : null; // 鏍囧噯杈撳嚭娴� 
                 StreamReader se = p.StandardError; // 鏍囧噯閿欒娴�
 
                 LogOut.Info("cmd = " + string.Join("锛�", list));
@@ -208,7 +208,7 @@
                 }
                 si.WriteLine("exit");
 
-                //string info = so.ReadToEnd();
+                string info = null == so ? null : so.ReadToEnd();
                 str = se.ReadToEnd();
 
                 //if (!string.IsNullOrEmpty(info)) LogOut.Debug(info);

--
Gitblit v1.9.3