From 31497bb69602433d94c8a28ea01c3ee3c7cc8576 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 24 十月 2019 14:32:30 +0800
Subject: [PATCH] 完全合并了Wjc,Xm 的 代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs
index dd788ba..c8e953e 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs
@@ -29,6 +29,10 @@
         /// 鑾峰彇寰楀埌浜嗘柊缃戝叧
         /// </summary>
         private bool newGatewayGetting = false;
+        /// <summary>
+        /// 缃戝叧妫�娴嬩腑
+        /// </summary>
+        private string isGatewayChecking = "0";
 
         #endregion
 
@@ -111,7 +115,7 @@
             btnMsg1.Y = picGwImage.Bottom + Application.GetRealHeight(112);
             btnMsg1.TextID = R.MyInternationalizationString.uSearchGatewayFailMsg1;
             bodyFrameLayout.AddChidren(btnMsg1);
-            //1.闀挎寜ZB/RST閿�20绉掞紝缃戝叧鎭㈠鍑哄巶璁剧疆锛屾寚绀虹伅鍏ㄩ儴鐔剓0}鐏悗锛岄噸鏂板叆缃戙��
+            //1.闀挎寜ZB/RST閿�20绉掞紝缃戝叧鎭㈠鍑哄巶璁剧疆锛屾寚绀虹伅鍏ㄩ儴鐔勭伃鍚庯紝閲嶆柊鍏ョ綉銆�
             var btnMsg2 = new NormalViewControl(930, 100, true);
             btnMsg2.X = Application.GetRealWidth(75);
             btnMsg2.Y = btnMsg1.Bottom + Application.GetRealHeight(35);
@@ -120,7 +124,7 @@
             btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor1;
             btnMsg2.IsMoreLines = true;
             bodyFrameLayout.AddChidren(btnMsg2);
-            //2.鐐规寜HID/WCFG閿紝杩涘叆缃戝叧鎹㈢粦妯″紡锛岀郴缁熸寚绀虹伅蹇棯{0}5绉掋��
+            //2.鐐规寜HID/WCFG閿紝杩涘叆缃戝叧鎹㈢粦妯″紡锛岀郴缁熸寚绀虹伅蹇棯5绉掋��
             var btnMsg3 = new NormalViewControl(930, 100, true);
             btnMsg3.X = Application.GetRealWidth(75);
             btnMsg3.Y = btnMsg2.Bottom + Application.GetRealHeight(12);
@@ -214,7 +218,7 @@
             picGwImage.AddChidren(btnRound);
 
             string strMsg = btnMsg.Text;
-            HdlThreadLogic.Current.RunThread(async () =>
+            HdlThreadLogic.Current.RunThread(() =>
             {
                 //娓呯┖鍏ㄩ儴鍒楄〃
                 HdlGatewayLogic.Current.ClearAllRealGateway();
@@ -229,8 +233,22 @@
                     maxCount--;
                     if (maxCount % 4 == 0)
                     {
-                        //姣�2绉掓娴嬫悳绱㈠埌鐨勭綉鍏�
-                        await this.CheckZbGatewayAndSetRow();
+                        lock(isGatewayChecking)
+                        {
+                            if (isGatewayChecking != "1")
+                            {
+                                isGatewayChecking = "1";
+                                HdlThreadLogic.Current.RunThread(async () =>
+                                {
+                                    //姣�2绉掓娴嬫悳绱㈠埌鐨勭綉鍏�
+                                    await this.CheckZbGatewayAndSetRow();
+                                    lock (isGatewayChecking)
+                                    {
+                                        isGatewayChecking = "0";
+                                    }
+                                });
+                            }
+                        }
                     }
                     if (this.newGatewayGetting == true)
                     {
@@ -265,12 +283,15 @@
                         this.InitFailMiddleFrame();
                     });
                 }
-                else
+                else if (newGatewayGetting == true)
                 {
                     HdlThreadLogic.Current.RunMain(() =>
                     {
-                        var form = new WiredGatewayListForm();
-                        this.AddFromAndRemoveNowForm(form, listZbGateway, dicZbGatewayDiv);
+                        if (this.Parent != null)
+                        {
+                            var form = new WiredGatewayListForm();
+                            this.AddFromAndRemoveNowForm(form, listZbGateway, dicZbGatewayDiv);
+                        }
                     });
                 }
             });

--
Gitblit v1.8.0