内存使用情况监控

Posted on 2019-01-24 20:41  努力成长静待花开  阅读(349)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  ComputerInfo类的相关属性    (using Microsoft.VisualBasic.Devices;)

  

实现代码:

        private void timer1_Tick(object sender, EventArgs e)
        {
            ComputerInfo comp=new ComputerInfo();
            textBox1.Text = Convert.ToString(comp.TotalPhysicalMemory / 1024 / 1024);
            textBox2.Text = Convert.ToString(comp.AvailablePhysicalMemory / 1024 / 1024);
            textBox3.Text = Convert.ToString(comp.TotalVirtualMemory / 1024 / 1024);
            textBox4.Text = Convert.ToString(comp.AvailableVirtualMemory / 1024 / 1024);
        }