using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; namespace HKHelper { public class Singleton where T : new() { private static object _async = new object(); private static T _instance; static readonly Lazy instance = new(); /// /// 获取实例 /// /// public static T GetInstance() { return instance.Value; } } public class HKHelper : Singleton { /// /// 判断网络状况的方法,返回值true为连接,false为未连接 /// /// /// /// [DllImport("wininet")] public extern static bool InternetGetConnectedState(out int conState, int reder); /// /// 获取当前网络连接状态 /// /// 成功连接网络返回 true,未连接返回 false public bool GetNetworkState() { return InternetGetConnectedState(out int i, 0); } } }