diff --git a/Netch/Forms/MainForm.Status.cs b/Netch/Forms/MainForm.Status.cs index 5b3c405c..9c7d4f1f 100644 --- a/Netch/Forms/MainForm.Status.cs +++ b/Netch/Forms/MainForm.Status.cs @@ -73,7 +73,7 @@ namespace Netch.Forms ProfileGroupBox.Enabled = true; - UsedBandwidthLabel.Visible /*= UploadSpeedLabel.Visible*/ = DownloadSpeedLabel.Visible = true; + UsedBandwidthLabel.Visible /*= UploadSpeedLabel.Visible*/ = DownloadSpeedLabel.Visible = Bandwidth.NetTrafficAvailable; break; case State.Stopping: ControlButton.Enabled = false; diff --git a/Netch/Utils/Bandwidth.cs b/Netch/Utils/Bandwidth.cs index 2b830ef2..e1fc1530 100644 --- a/Netch/Utils/Bandwidth.cs +++ b/Netch/Utils/Bandwidth.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -48,12 +49,16 @@ namespace Netch.Utils return mStrSize; } + public static bool NetTrafficAvailable => /*Global.Settings.EnableNetTraffic && */Environment.OSVersion.Version.Major >= 10; + /// /// 根据程序名统计流量 /// - /// public static void NetTraffic(Server server, Mode mode) { + if (!NetTrafficAvailable) + return; + var counterLock = new object(); //int sent = 0; @@ -94,7 +99,7 @@ namespace Netch.Utils if (processList.Contains(data.ProcessID)) { lock (counterLock) - received += ulong.Parse(data.size.ToString()); + received += (ulong) data.size; // Debug.WriteLine($"TcpIpRecv: {ToByteSize(data.size)}"); } @@ -104,7 +109,7 @@ namespace Netch.Utils if (processList.Contains(data.ProcessID)) { lock (counterLock) - received += ulong.Parse(data.size.ToString()); + received += (ulong) data.size; // Debug.WriteLine($"UdpIpRecv: {ToByteSize(data.size)}"); }