Windows 10 以下禁用流量统计

This commit is contained in:
ChsBuffer
2020-08-31 17:44:21 +08:00
parent 60aa010096
commit efa1b2ed54
2 changed files with 10 additions and 5 deletions

View File

@@ -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;

View File

@@ -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;
/// <summary>
/// 根据程序名统计流量
/// </summary>
/// <param name="ProcessName"></param>
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)}");
}