From 83d3a5b39efa7bea47ed418cab8ebc2f9fec8b14 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 23 十二月 2020 12:44:24 +0800
Subject: [PATCH] 20201223-4

---
 HDL_ON/Common/ApiUtlis.cs |   47 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs
index c564f63..d1aace8 100644
--- a/HDL_ON/Common/ApiUtlis.cs
+++ b/HDL_ON/Common/ApiUtlis.cs
@@ -55,7 +55,7 @@
             return result;
         }
 
-        public bool DownloadDataComplete = false;
+        public bool DownloadDataComplete = true;
         /// <summary>
         /// 涓嬭浇鏁版嵁
         /// </summary>
@@ -63,6 +63,8 @@
         {
             if (MainPage.InternetStatus == 0)
                 return;
+            //绾跨▼寮�濮嬫椂闂�
+            var beginTime = DateTime.Now.AddSeconds(6);
 
             DownloadDataComplete = false;
 
@@ -72,10 +74,11 @@
 
             string code = StateCode.SUCCESS;
 
-            new System.Threading.Thread(() => {
+            var downloadDataThread = new System.Threading.Thread(() =>
+            {
                 //===================鍒锋柊Token=======================
                 code = Ins.HttpRequest.RefreshToken();
-                if(code != StateCode.SUCCESS)
+                if (code != StateCode.SUCCESS)
                 {
                     MainPage.Log($"鍒锋柊token澶辫触");
                     return;
@@ -191,7 +194,7 @@
                     var pack = Ins.HttpRequest.GetSceneList();
                     if (pack.Code == StateCode.SUCCESS)
                     {
-                        MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛");//:\r\n{pack.Data.ToString()}");
+                        MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛");
                         var sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString());
                         if (sceneList != null)
                         {
@@ -237,18 +240,50 @@
 
                     //===================璇诲彇閫昏緫鍒楄〃==========================
                     UI.UI2.Intelligence.Automation.MainView.GetLogicList();
-                }catch(Exception ex)
+                }
+                catch (Exception ex)
                 {
                     MainPage.Log($"鏁版嵁鍒濆鍖栧け璐ワ細{ex.Message}");
                 }
                 finally
                 {
-                    Application.RunOnMainThread(() => {
+                    Application.RunOnMainThread(() =>
+                    {
+                        beginTime = DateTime.MinValue;
                         DownloadDataComplete = true;
                         waitPage.Hide();
                         waitPage.RemoveFromParent();
                     });
                 }
+            });
+            downloadDataThread.IsBackground = true;
+            downloadDataThread.Start();
+
+            //缃戠粶鍗¢】锛岀粓姝笅杞界嚎绋�
+            new System.Threading.Thread(() =>
+            {
+                while (beginTime < DateTime.Now)
+                {
+                    if (DownloadDataComplete)
+                    {
+                        break;
+                    }
+                    System.Threading.Thread.Sleep(100);
+                }
+                if (!DownloadDataComplete)
+                {
+                    downloadDataThread.Abort();
+                }
+                DownloadDataComplete = true;
+                Application.RunOnMainThread(() =>
+                {
+                    waitPage.Hide();
+                    waitPage.RemoveFromParent();
+                });
+                //鍒濆鍖栨暟鎹�
+                //SpatialInfo.CurrentSpatial.Clear();
+
+
             })
             { IsBackground = true }.Start();
         }

--
Gitblit v1.8.0