VB 2010 RAM监视器问题 [英] VB 2010 RAM Monitor Problem

查看:104
本文介绍了VB 2010 RAM监视器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家快来参加论坛:D.在我正在执行的项目的代码部分中需要一些帮助.我的RAM监视器似乎无法正常工作,有时在与任务管理器配合使用时,其值会加倍或显示不正确的值.我正在使用的代码如下:

Hi people, just signed up to the forum :D. need a little help with a section of my code for a project I am doing. my RAM monitor doesn''t seem to work properly and sometimes doubles the value or displays a incorrect value when put against task manager. the code I am using is below:

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    Dim SystemRAM As Integer = CDec(PerformanceCounter3.NextValue.ToString())        
    Dim SystemRAM2 As Integer

    SystemRAM2 = 80 - SystemRAM                                                      
    Label34.Text = SystemRAM2.ToString() & " %"                                        
    On Error Resume Next                                                             
    ProgressBar3.Value = SystemRAM2.ToString
End Sub



希望有人能帮忙???

欢呼声
ElmoK11



hope someone can help ???

cheers
ElmoK11

推荐答案

如果不了解PerformanceCounter3的创建方式,很难提供太多帮助.

为了将来自己的利益,您还可以考虑为变量使用更多的描述性名称.在6个月的时间里,您可能不会记住"PerformanceCounter3"的作用,而您可能会记得"RAMPerformanceCounter3"的用途.


在您回答/评论之后:

对我来说,为什么要计算80 - SystemRAM(这并不意味着它是错误的,只是我无法理解80的来源:))对我来说并不明显,但是看来您正在尝试获取可用内存". br/>
如果是这样,您是否尝试过以下方法:
Without seeing how PerformanceCounter3 is created, it is difficult to give much help.

You might also, for your own benefit in the future, consider using more descriptive names for your variables. In 6 months time you probably won''t remember what ''PerformanceCounter3'' does, whereas you probably would remember what ''RAMPerformanceCounter'' is for.


After your answer/comment:

It is not obvious to me why you are calculating 80 - SystemRAM (That doesn''t mean it is wrong, just that I cannot understand where the 80 comes from :) ) but it looks like you are trying to get Available Memory.

If so have you tried something like:
category name: memory
counter name: Available MBytes
generate member:true
instance lifetime: Global
modifiers: friend



看看它是否也波动

[/Edit]



to see if that fluctuates as well

[/Edit]


这篇关于VB 2010 RAM监视器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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