From 5bf1b91009a182188d6d2245aa71653801eea60b Mon Sep 17 00:00:00 2001
From: wells <123>
Date: 星期日, 12 七月 2020 18:09:54 +0800
Subject: [PATCH] debug

---
 src/Bro.UI.Config/MainFrm.cs |   66 ++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/src/Bro.UI.Config/MainFrm.cs b/src/Bro.UI.Config/MainFrm.cs
index e7940f5..b2d717e 100644
--- a/src/Bro.UI.Config/MainFrm.cs
+++ b/src/Bro.UI.Config/MainFrm.cs
@@ -74,10 +74,10 @@
             //});
 
             m_deserializeMenuFrm = new DeserializeDockContent(GetMenuFromPersistString);
-            LoadLayoutFromXML(m_deserializeMenuFrm);
-
             m_deserializeDeviceRunFrm = new DeserializeDockContent(GetAllFormPersistString);
-            _allMenuLoadDoneHandle.Set();
+
+            //LoadLayoutFromXML(m_deserializeMenuFrm);
+            //_allMenuLoadDoneHandle.Set();
 
             Text = SettingHelper.GetProgramDescription();
             string iconPath = SettingHelper.GetProgramIcon();
@@ -90,7 +90,9 @@
         private void RegisterEvent(MenuFrmBase dockFrm)
         {
             dockFrm.OnUploadProcess = DockFrm_OnUploadProcess;
-            dockFrm.OnLogMsgOutput = DockFrm_OnLogMsgOutput;
+
+            dockFrm.OnLogMsgOutput -= DockFrm_OnLogMsgOutput;
+            dockFrm.OnLogMsgOutput += DockFrm_OnLogMsgOutput;
 
             //if (dockFrm is FrmDevices)
             //{
@@ -155,21 +157,32 @@
                 CloseAllDeviceFrm();
                 LoadDevices();
 
-                foreach (var dock in dockPanelMain.Contents)
+                try
                 {
-                    MenuFrmBase m = dock as MenuFrmBase;
-
-                    if (m != null && m.Id != frmId)
+                    foreach (var dock in dockPanelMain.Contents)
                     {
-                        m.DownloadProcess(process);
+                        MenuFrmBase m = dock as MenuFrmBase;
+
+                        if (m != null && m.Id != frmId)
+                        {
+                            m.DownloadProcess(process);
+                        }
                     }
+                }
+                catch (Exception ex)
+                {
                 }
             });
         }
 
-        private void Process_OnAlarmUpdate(string alarmMsg)
+        private async void Process_OnAlarmUpdate(string alarmMsg)
         {
-            tsslWarning.Text = alarmMsg;
+            this.BeginInvoke(new Action(() =>
+            {
+                tsslWarning.Text = alarmMsg;
+            }));
+
+            await Task.Delay(100);
         }
 
         private ToolStripMenuItem GetMatchNode(ToolStripItemCollection items, string parentMenuCode)
@@ -247,13 +260,16 @@
 
         private void MainFrm_Load(object sender, EventArgs e)
         {
+            LoadLayoutFromXML(m_deserializeMenuFrm);
+            _allMenuLoadDoneHandle.Set();
+
             AdvancedPwdFrm.OnLoginOK = OnLoginOK;
 
-            SpinWait wait = new SpinWait();
-            while (_process == null)
-            {
-                wait.SpinOnce();
-            }
+            //SpinWait wait = new SpinWait();
+            //while (_process == null)
+            //{
+            //    wait.SpinOnce();
+            //}
             LoadLayoutFromXML(m_deserializeDeviceRunFrm);
         }
 
@@ -310,7 +326,7 @@
 
         private void OnLoginOK(bool isLogin)
         {
-            IsLogin = true;
+            IsLogin = isLogin;
         }
         #endregion
 
@@ -535,10 +551,10 @@
 
                 dockFrm.Text = desc[2];
 
-                if (_process != null)
-                {
-                    dockFrm.DownloadProcess(_process);
-                }
+                //if (_process != null)
+                //{
+                //    dockFrm.DownloadProcess(_process);
+                //}
 
                 dockFrm.SetLoginStatus(IsLogin);
 
@@ -573,10 +589,10 @@
 
                 dockFrm.Text = desc[2];
 
-                if (_process != null)
-                {
-                    dockFrm.DownloadProcess(_process);
-                }
+                //if (_process != null)
+                //{
+                //    dockFrm.DownloadProcess(_process);
+                //}
 
                 dockFrm.SetLoginStatus(IsLogin);
 

--
Gitblit v1.8.0