如何獲取C#代碼中系統的CPU,RAM和磁盤驅動器使用情況?獲取C#中當前CPU,RAM和磁盤驅動器的使用情況
20
A
回答
22
2
在這裏是將輸出磁盤的使用,被在所使用的總的磁盤%的溶液Timer99輪詢的時間:
using System;
using System.Diagnostics;
using System.Windows;
namespace diskpercent
{
public partial class MainWindow : Window
{
DispatcherTimer Timer99 = new DispatcherTimer();
public MainWindow()
{
InitializeComponent();
Timer99.Tick += Timer99_Tick; // don't freeze the ui
Timer99.Interval = new TimeSpan(0, 0, 0, 0, 1024);
Timer99.IsEnabled = true;
}
public PerformanceCounter myCounter =
new PerformanceCounter("PhysicalDisk", "% Disk Time", "_Total");
public Int32 j = 0;
public void Timer99_Tick(System.Object sender, System.EventArgs e)
{
//Console.Clear();
j = Convert.ToInt32(myCounter.NextValue());
//Console.WriteLine(j);
textblock1.Text = j.ToString();
}
}
}
,這裏是常見的性能計數器的列表:
PerformanceCounter("Processor", "% Processor Time", "_Total");
PerformanceCounter("Processor", "% Privileged Time", "_Total");
PerformanceCounter("Processor", "% Interrupt Time", "_Total");
PerformanceCounter("Processor", "% DPC Time", "_Total");
PerformanceCounter("Memory", "Available MBytes", null);
PerformanceCounter("Memory", "Committed Bytes", null);
PerformanceCounter("Memory", "Commit Limit", null);
PerformanceCounter("Memory", "% Committed Bytes In Use", null);
PerformanceCounter("Memory", "Pool Paged Bytes", null);
PerformanceCounter("Memory", "Pool Nonpaged Bytes", null);
PerformanceCounter("Memory", "Cache Bytes", null);
PerformanceCounter("Paging File", "% Usage", "_Total");
PerformanceCounter("PhysicalDisk", "Avg. Disk Queue Length", "_Total");
PerformanceCounter("PhysicalDisk", "Disk Read Bytes/sec", "_Total");
PerformanceCounter("PhysicalDisk", "Disk Write Bytes/sec", "_Total");
PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Read", "_Total");
PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Write", "_Total");
PerformanceCounter("PhysicalDisk", "% Disk Time", "_Total");
PerformanceCounter("Process", "Handle Count", "_Total");
PerformanceCounter("Process", "Thread Count", "_Total");
PerformanceCounter("System", "Context Switches/sec", null);
PerformanceCounter("System", "System Calls/sec", null);
PerformanceCounter("System", "Processor Queue Length", null);
相關問題
- 1. 如何使用.NET CORE獲取C#Web應用程序當前的CPU/RAM /磁盤使用情況?
- 2. 如何在C++中獲取當前的CPU和RAM使用情況?
- 3. 如何在Python中獲取當前的CPU和RAM使用情況?
- 4. 如何在VB 6中獲取當前的CPU和RAM使用情況?
- 5. 使用WMI獲取C#中每個進程的CPU和RAM使用情況?
- 6. Ruby獲取可用磁盤驅動器
- 7. 使用ruby或cli獲取當前的cpu使用情況
- 8. 如何使用python或WMI設置RAM磁盤驅動器?
- 9. 在asp.net框架中使用c#獲取當前cpu使用情況
- 10. 獲取內存使用率,CPU使用率,在Windows 10中的磁盤使用情況UWP C#
- 11. 通過Java獲得當前JVM的真實RAM使用情況
- 12. 如何從aws服務器詳細信息(如cpu ram和硬盤使用情況)獲取實時數據
- 13. AS400 jt400獲取RAM使用情況
- 14. 如何獲取C#(託管代碼)中的* THREAD *的CPU使用率和/或RAM使用情況?
- 15. 在Android上獲取CPU,RAM和網絡使用情況統計信息
- 16. 如何使用PowerShell查找CPU和RAM使用情況?
- 17. WinForms:驅動器中沒有磁盤。請將磁盤插入驅動器
- 18. 從SoftLayer API獲取磁盤使用情況
- 19. 當RAM用完時寫入磁盤java
- 20. Couchbase數據/磁盤使用情況以及RAM /配額使用數據
- 21. SQLite表磁盤使用情況
- 22. VB.NET:監控磁盤使用情況
- 23. netbeans優化磁盤使用情況
- 24. 在構建期間如何測量CPU,內存和磁盤使用情況?
- 25. DataDog中的容器磁盤使用情況
- 26. Eclipse Galileo中缺少磁盤驅動器
- 27. 打印CPU使用率,磁盤使用率,RAM使用率的bash腳本
- 28. 無驅動器盤符的驅動器的Powershell可用磁盤空間
- 29. 度量以計算和比較Android中的RAM和CPU使用情況
- 30. Aerospike硬盤驅動器/內存使用情況
如何獲得磁盤驅動器使用? – Sauron 2009-08-10 05:07:39
通過性能計數器類。通過改變類別。 – Aamir 2009-08-10 05:28:36