diff --git a/Netch/Global.cs b/Netch/Global.cs index c415d1a8..68a8478c 100644 --- a/Netch/Global.cs +++ b/Netch/Global.cs @@ -32,7 +32,7 @@ namespace Netch /// /// 主窗体的静态实例 /// - private static Lazy _mainForm = new(() => new MainForm()); + private static readonly Lazy LazyMainForm = new(() => new MainForm()); public static readonly Mutex Mutex = new(false, "Global\\Netch"); @@ -61,9 +61,9 @@ namespace Netch { public static readonly bool IsWindows10Upper = Environment.OSVersion.Version.Major >= 10; - private static bool? _supportFakeDns; + private static readonly Lazy LazySupportFakeDns = new(() => new TUNTAPController().TestFakeDNS()); - public static bool SupportFakeDns => _supportFakeDns ??= new TUNTAPController().TestFakeDNS(); + public static bool SupportFakeDns => LazySupportFakeDns.Value; } /// @@ -115,7 +115,7 @@ namespace Netch /// /// 主窗体的静态实例 /// - public static MainForm MainForm => _mainForm.Value; + public static MainForm MainForm => LazyMainForm.Value; public static JsonSerializerOptions NewDefaultJsonSerializerOptions => new() {