终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

UniversalHelper.cs 1.4 KiB

2 anni fa
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //using GVL;
  2. using Microsoft.Win32;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Runtime.InteropServices;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. namespace BPASmartClient.Helper
  11. {
  12. /// <summary>
  13. /// 其它通用库
  14. /// </summary>
  15. public class UniversalHelper:Singleton<UniversalHelper>
  16. {
  17. [DllImport("wininet")]
  18. //判断网络状况的方法,返回值true为连接,false为未连接
  19. public extern static bool InternetGetConnectedState(out int conState, int reder);
  20. /// <summary>
  21. /// 获取当前网络连接状态
  22. /// </summary>
  23. /// <returns>成功连接网络返回 true,未连接返回 false</returns>
  24. public bool GetNetworkState()
  25. {
  26. return InternetGetConnectedState(out int i, 0);
  27. }
  28. public void Init()
  29. {
  30. //while (!GVL_VAR.GetInstance.NetworkConnectState)
  31. //{
  32. // //GVL_VAR.GetInstance.NetworkConnectState = GetNetworkState();
  33. // Thread.Sleep(1000);
  34. //}
  35. //ThreadManagerment.GetInstance.StartLong(new Action(() =>
  36. //{
  37. // //GVL_VAR.GetInstance.NetworkConnectState = GetNetworkState();
  38. // Thread.Sleep(1000);
  39. //}), "网络监听状态");
  40. }
  41. }
  42. }