From e5f993f52e09eb46878baced83bb8492f147d41c Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 04 十一月 2019 17:58:40 +0800
Subject: [PATCH] 2019-11-04-1

---
 ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs |   39 ++++++++++++++++++++++++++++++---------
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs
index dd788ba..29ece02 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);
+                        }
                     });
                 }
             });
@@ -369,7 +390,7 @@
                 if (mode != GatewayBindMode.BindAgain)
                 {
                     //鎴戣寰楄繖閲岄渶瑕佽幏鍙栦竴涓嬫柊缃戝叧鐨勮澶囧垪琛�
-                    await Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(way);
+                    Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(way);
                 }
             }
             return true;

--
Gitblit v1.8.0