List all processes and their current memory & CPU consumption?

怎甘沉沦 提交于 2019-11-27 00:46:53

问题


How can I get a list of all processes in C# and then for each process current memory and CPU consumption?

Sample code is highly appreciated.


回答1:


The Process class has a GetProcesses method that will let you enumerate the running processes and list a bunch of stats like memory usage and CPU time. Look at the documentation under properties for the stats.

Memory usage is a complex matter. There is really no single number, that describe the usage. Please see Russinovich's excellent series on the matter. The first installment is here: http://blogs.technet.com/markrussinovich/archive/2008/07/21/3092070.aspx



来源:https://stackoverflow.com/questions/1248129/list-all-processes-and-their-current-memory-cpu-consumption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!