예제 #1
0
 /// <summary>
 /// 定时更新数据
 /// </summary>
 private void InitUpdateTheard()
 {
     if (updateTimer == null)
     {
         updateSpan  = TimeSpan.FromSeconds(2);
         updateTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) => {
             if (wanInfo == null)
             {
                 wanInfo = await RouterAPI.GetWANinfo();
             }
             netRate    = await RouterAPI.GetNetRate();
             cpuMemInfo = await RouterAPI.GetCpuMemInfo();
             clients    = await RouterAPI.GetClients();
             devRate    = await RouterAPI.GetDeviceRate();
             banList    = await RouterAPI.FireWall.GetBanList();
             if (wlanInfo == null)
             {
                 wlanInfo = await RouterAPI.GetWLANInfo();
             }
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {
                 UpdateUI();
             });
         }, updateSpan);
     }
 }
예제 #2
0
 /// <summary>
 /// 定时更新数据
 /// </summary>
 private void InitUpdateTheard()
 {
     if (updateTimer == null)
     {
         updateSpan  = TimeSpan.FromSeconds(2);
         updateTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) => {
             if (App.DemoAccount)
             {
                 await Dispatcher.RunAsync(CoreDispatcherPriority.High, async() => {
                     data = await MainPageData.GetDemoData();
                     UpdateUI();
                 });
                 updateTimer.Cancel();
             }
             else
             {
                 if (data == null)
                 {
                     data = new MainPageData();
                 }
                 if (data.wanInfo == null)
                 {
                     data.wanInfo = await RouterAPI.GetWANinfo();
                 }
                 data.netRate    = await RouterAPI.GetNetRate();
                 data.cpuMemInfo = await RouterAPI.GetCpuMemInfo();
                 data.clients    = await RouterAPI.GetClients();
                 data.devRate    = await RouterAPI.GetDeviceRate();
                 data.banList    = await RouterAPI.FireWall.GetBanList();
                 if (data.wlanInfo == null)
                 {
                     data.wlanInfo = await RouterAPI.GetWLANInfo();
                 }
                 await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {
                     UpdateUI();
                 });
             }
         }, updateSpan);
     }
 }