获取设备的CPU利用率,可用RAM的WinCE在C# [英] Getting the device's CPU utilization and free RAM on WinCE in C#

查看:374
本文介绍了获取设备的CPU利用率,可用RAM的WinCE在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找获得总的CPU使用率和可用RAM的设备上在C#中量的替代办法。

I'm looking for alternative ways of obtaining the total CPU utilization percentage and the amount of free RAM on the device in C#.

这里有描述一个非常简单的解决方案: http://zamov.online .FR / EXHTML / CSHARP / CSHARP%5F927308.html

There is an extremely easy solution described here: http://zamov.online.fr/EXHTML/CSharp/CSharp%5F927308.html

不过,PerformanceCounter类不包含在.NET Compact Framework 3.5的。

However, the PerformanceCounter class is not included in the .NET Compact Framework 3.5.

有没有其他办法?

感谢:)

推荐答案

可用RAM是相当容易的 - 尽管你有物理和虚拟抗衡 - 无一不是重要的。您的P / Invoke GlobalMemoryStatus 为(像往常一样自卫队拥有它已经包裹在一个更友好的对象模型以及)。

Free RAM is fairly easy - though you have both Physical and Virtual to contend with - and both are important. You P/Invoke GlobalMemoryStatus for that (as usual the SDF has it already wrapped in a more friendly object model as well).

CPU使用率是不同的动物完全。在PC上,你有一个很好的寄存器,让您轻松,廉价获得CPU的使用情况。在ARM(这是在你的WinMo设备)你没有这一点。它可以使用 TOOLHELP的API 的组合和的 GetThreadTimes ,但它是非常重手,计算它使用了大量的CPU全部由自己的过程。一般来说让CPU使用率是不值得牺牲的code或得到它所需的执行时间。

CPU usage is a different animal altogether. On the PC you have a nice processor register that gives you easy, cheap access to the CPU usage. On ARM (which is what's in your WinMo device) you don't have that. It can be calculated using a mix of the Toolhelp APIs and GetThreadTimes, but it's very heavy handed and the process of calculating it uses a lot of CPU all by itself. Generally speaking getting CPU usage isn't worth the expense of the code or the execution time required to get it.

这篇关于获取设备的CPU利用率,可用RAM的WinCE在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆