列出所有进程及其当前内存和内存 CPU消耗?

发布于 2024-07-30 19:14:41 字数 68 浏览 2 评论 0原文

如何获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长梦不多时 2024-08-06 19:14:41

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文