日期:2014-05-18 浏览次数:20780 次
private void load_Monitor() { listView1.Items.Clear(); PerformanceCounterCategory category = new PerformanceCounterCategory("Web Service"); int i; i = 0; foreach (string str in category.GetInstanceNames()) { i++; PerformanceCounter counter1 = new PerformanceCounter(category.CategoryName,"Bytes Sent/sec",str); PerformanceCounter counter2 = new PerformanceCounter(category.CategoryName,"Files/sec",str); ListViewItem listItem = new ListViewItem(); listItem.SubItems[0].Text = i.ToString(); listItem.SubItems.Add(str); listItem.SubItems.Add(counter1.NextValue().ToString()); listItem.SubItems.Add(counter2.NextValue().ToString()); listView1.Items.Add(listItem); } }