列出所有进程及其当前内存和内存 CPU消耗?
如何获取 C# 中所有进程的列表,然后获取每个进程当前的内存和 CPU 消耗?
示例代码受到高度赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Process 类 有一个 GetProcesses 方法,可以让您枚举正在运行的进程并列出一堆统计信息,例如内存使用情况和 CPU 时间。 查看属性下的文档以获取统计信息。
内存使用是一个复杂的问题。 实际上没有一个数字可以描述其用法。 请参阅 Russinovich 关于此事的精彩系列。 第一期在这里:http://blogs.technet.com /markrussinovich/archive/2008/07/21/3092070.aspx
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