0

我尝试在 c# 中创建一个 performanceCounter 来监视我的浏览器的网络连接;

当我显示查找我的浏览器 instanceName 的列表时,CounterPerformance“.NET CLR Networking 4.0.0.0”没有监控这...

我创建了我的计数器:

bytesSent = new PerformanceCounter();
bytesSent.CategoryName = ".NET CLR Networking 4.0.0.0";
bytesSent.CounterName = "Bytes Sent";
bytesSent.InstanceName = instanceName; // instanceName of my browser.
bytesSent.ReadOnly = true;

我显示了监控的实例列表:

PerformanceCounterCategory category = new PerformanceCounterCategory(".NET CLR Networking 4.0.0.0");

string[] listMonitoredApplication = category.GetInstanceNames();
foreach (string monitoredInstanceName in listMonitoredApplication)
{
    Console.WriteLine(" - " + monitoredInstanceName);
}

我每 1 秒显示一次 performanceCounter 列表,在列表中,只有:

- myApplicationInstanceName
- _global_

你知道为什么我的浏览器 PerformanceCounter 没有创建吗?

谢谢你。

4

1 回答 1

0

It is because the browser doesn't use .NET framework classes to transfer data. Browsers use native code.

You'll need to use a different performance counter, like those in the "Network Interface" category. With the added wrinkle that the tcp/ip driver stack doesn't keep statistics for individual processes, only for a particular network interface. No workaround for that.

于 2012-10-23T17:52:21.077 回答