码迷,mamicode.com
首页 > 系统相关 > 详细

获得特定进程信息

时间:2017-01-19 18:12:20      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:sse   进程   工作   memory   stat   form   string   and   void   

/// 
        /// 获得特定进程信息
        /// 
        /// 进程名称
        public static void GetProcessInfo(string processName)
        {
            Process[] processes = Process.GetProcessesByName(processName);
            foreach (Process instance in processes)
            {
                Console.WriteLine("");
                Console.WriteLine("ProcessName:" + instance.ProcessName);
                try
                {

//单位:KB
                    Console.WriteLine("提交大小\t" + instance.PagedMemorySize64 / 1024);
                    Console.WriteLine("工作设置(内存)\t" + instance.WorkingSet64 / 1024);
                    Console.WriteLine("线程数\t" + instance.Threads.Count);
                    Console.WriteLine("句柄数\t" + instance.HandleCount);

                }
                catch { }
            }

            //PerformanceCounter TotalCpuUsage = new PerformanceCounter("Process", "% Processor Time", "Idle");
            //double total1 = 0;
            //while (true)
            //{
            //    if (total1 == 0)
            //    {
            //        total1 = processes[0].TotalProcessorTime.TotalMilliseconds;
            //    }
            //    else
            //    {
            //        total1 += processes[0].TotalProcessorTime.TotalMilliseconds - total1;
            //    }
            //    Thread.Sleep(1000);
            //}
        }

获得特定进程信息

标签:sse   进程   工作   memory   stat   form   string   and   void   

原文地址:http://www.cnblogs.com/94cool/p/6307238.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!