标签:style blog color os io for ar div
private void button1_Click(object sender, EventArgs e) { listBox_thread_list.Items.Clear(); Process[] processes; processes = System.Diagnostics.Process.GetProcesses(); Process process; for (int i = 0; i < processes.Length; i++) { process = processes[i]; // str = str + Convert.ToString(process.Id) + ": "+process.ProcessName+"\r\n"; listBox_thread_list.Items.Add(process.Id + ":"+process.ProcessName); } //System.Windows.Forms.MessageBox.Show(str); // textBox_thread_list.Text = processes[0].ProcessName.ToString(); } private void get_this_thread_Click(object sender, EventArgs e) { string item = null; try { item = listBox_thread_list.SelectedItem.ToString(); }catch (ArgumentException e1) { throw new ArgumentException("出错啦!", e1); } string[] items = item.Split(new Char[]{‘:‘}); int thread_id = Convert.ToInt32(items[0]); string thread_name = items[1]; long thread_RAM = Process.GetProcessById(thread_id).WorkingSet64; using (var private_RAM = new PerformanceCounter("Process", "Working Set - Private", thread_name)) System.Windows.Forms.MessageBox.Show("线程ID:" + thread_id + "\n线程名:" + thread_name + "\n线程工作集:" + (thread_RAM) / 1024 + "Kb" + "\n线程专用内存:" + (private_RAM.NextValue() / 1024) + "Kb"); }
标签:style blog color os io for ar div
原文地址:http://www.cnblogs.com/owl-home/p/3923560.html