From efa1b2ed545e48ee9b1e4fee9820210cdd15c0f5 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Mon, 31 Aug 2020 17:44:21 +0800 Subject: [PATCH] =?UTF-8?q?Windows=2010=20=E4=BB=A5=E4=B8=8B=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E6=B5=81=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Netch/Forms/MainForm.Status.cs | 2 +- Netch/Utils/Bandwidth.cs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) 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)}"); }