2012-10-23 16 views
0

我嘗試在c#中創建一個performanceCounter用於監視我的瀏覽器的網絡連接;.NET CLR Networking 4.0.0.0 - >創建性能計數器

當我顯示的列表中找到我的瀏覽器實例名,這不是由CounterPerformance」 .NET CLR網絡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); 
} 

我顯示的PerformanceCounter的列表中的每1秒,然後在列表中有剛:

- myApplicationInstanceName 
- _global_ 

你有什麼想法,爲什麼我的瀏覽器PerformanceCounter沒有創建?

謝謝。

回答

0

這是因爲瀏覽器不使用.NET框架類來傳輸數據。瀏覽器使用本機代碼。

您需要使用與「網絡接口」類別中不同的性能計數器。由於tcp/ip驅動程序堆棧沒有保留單個進程的統計信息,只能針對特定的網絡接口添加皺紋。沒有解決方法。

+0

好的,謝謝你的解釋! 您是否知道,如果我想用其他解決方案檢測瀏覽器網絡監控?我實際上搜索Netsh trace的解決方案,但如果您有更好的解決方案,我很感興趣! :-) –