You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RootViewModel.cs 1.2 KiB

2 年之前
2 年之前
2 年之前
2 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using HKCardOut.Helper;
  2. using HKCardOUT.Helper;
  3. using Stylet;
  4. using System;
  5. using System.Threading;
  6. namespace HKCardOUT.ViewModels
  7. {
  8. public class RootViewModel : PropertyChangedBase
  9. {
  10. public RootViewModel()
  11. {
  12. MainThread();
  13. }
  14. #region 方法
  15. private void MainThread()
  16. {
  17. ThreadManage.GetInstance().StartLong(new Action(() =>
  18. {
  19. try
  20. {
  21. //1.检测网络上下线
  22. bool network = HKHelper.GetInstance().GetNetworkState();
  23. if (network != DataBus.NetWordState)
  24. {
  25. if (network) HandyControl.Controls.Growl.InfoGlobal("网络连接成功");
  26. else HandyControl.Controls.Growl.InfoGlobal("系统已离线,请连接网络!!!");
  27. DataBus.NetWordState = network;
  28. }
  29. Thread.Sleep(3000);
  30. }
  31. catch (Exception ex)
  32. {
  33. HandyControl.Controls.Growl.InfoGlobal(ex.Message);
  34. }
  35. }), "循环状态监测线程", false);
  36. }
  37. #endregion
  38. }
  39. }