| | |
| | | { |
| | | if (MainPage.InternetStatus == 0) |
| | | return; |
| | | //线程开始时间 |
| | | var beginTime = DateTime.MinValue; |
| | | |
| | | DownloadDataComplete = false; |
| | | |
| | |
| | | |
| | | 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; |
| | |
| | | |
| | | //===================读取逻辑列表========================== |
| | | 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(); |
| | | } |
| | | } |
| | | } |