wei
2020-12-23 f345087dbefecef9146fdb13481cb9ee3320d576
HDL_ON/Common/ApiUtlis.cs
@@ -63,6 +63,8 @@
        {
            if (MainPage.InternetStatus == 0)
                return;
            //线程开始时间
            var beginTime = DateTime.MinValue;
            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;
@@ -237,20 +240,51 @@
                    //===================读取逻辑列表==========================
                    UI.UI2.Intelligence.Automation.MainView.GetLogicList();
                }catch(Exception ex)
                }
                catch (Exception ex)
                {
                    MainPage.Log($"数据初始化失败:{ex.Message}");
                }
                finally
                {
                    Application.RunOnMainThread(() => {
                    Application.RunOnMainThread(() =>
                    {
                        beginTime = DateTime.Now;
                        DownloadDataComplete = true;
                        waitPage.Hide();
                        waitPage.RemoveFromParent();
                    });
                }
            })
            { IsBackground = true }.Start();
            });
            downloadDataThread.IsBackground = true;
            downloadDataThread.Start();
            //网络卡顿,终止下载线程
            new System.Threading.Thread(() => {
                while (beginTime.AddSeconds(6) > DateTime.Now)
                {
                    if(DownloadDataComplete)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(100);
                }
                if (DownloadDataComplete)
                {
                    //下载完成初始化数据
                    SpatialInfo.CurrentSpatial.Clear();
                }
                else
                {
                    downloadDataThread.Abort();
                    Application.RunOnMainThread(() => {
                        waitPage.Hide();
                        waitPage.RemoveFromParent();
                    });
                }
            }) { IsBackground = true }.Start();
        }
    }
}