using HKCardOut.Helper; using HKCardOUT.Helper; using Stylet; using System; using System.Threading; namespace HKCardOUT.ViewModels { public class RootViewModel : PropertyChangedBase { public RootViewModel() { MainThread(); } #region 方法 private void MainThread() { ThreadManage.GetInstance().StartLong(new Action(() => { try { //1.检测网络上下线 bool network = HKHelper.GetInstance().GetNetworkState(); if (network != DataBus.NetWordState) { if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功"); else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!"); DataBus.NetWordState = network; } Thread.Sleep(3000); } catch (Exception ex) { HandyControl.Controls.Growl.InfoGlobal(ex.Message); } }), "循环状态监测线程", false); } #endregion } }