Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. CPU Usage?

CPU Usage?

Scheduled Pinned Locked Moved Visual Basic
performancequestionmcp
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AliAmjad
    wrote on last edited by
    #1

    Actually I want to display the Amount of Available Memory and CPU Usage and also its history on Screen just like one on Task Manager. So far I am able to display the Available Memory on Screen by using a Performance Counter under Memory Category "Available KBytes". But how can i display the CPU Usage and its History. I am using the "% Processor Time" Performance counter but can't see anything happening on screen. What should i use for this purpose. Thanks for your cooperation ! AliAmjad(MCP)

    P 1 Reply Last reply
    0
    • A AliAmjad

      Actually I want to display the Amount of Available Memory and CPU Usage and also its history on Screen just like one on Task Manager. So far I am able to display the Available Memory on Screen by using a Performance Counter under Memory Category "Available KBytes". But how can i display the CPU Usage and its History. I am using the "% Processor Time" Performance counter but can't see anything happening on screen. What should i use for this purpose. Thanks for your cooperation ! AliAmjad(MCP)

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Would you care to show the code that you are using for the PerformanceCounter class? It sounds like it ought to be working. I've done this numerous times in the past and it works.

      "Find it your bloody self - immediately!" - Dave Kreskowiak

      A 1 Reply Last reply
      0
      • P Paul Conrad

        Would you care to show the code that you are using for the PerformanceCounter class? It sounds like it ought to be working. I've done this numerous times in the past and it works.

        "Find it your bloody self - immediately!" - Dave Kreskowiak

        A Offline
        A Offline
        AliAmjad
        wrote on last edited by
        #3

        I am using the RawValue Property of "Available KBytes" Performance Counter and also used the same one for "% Processor Time" under a Timer which updates the Text of the Label after every Second But I Get always a '0' for "% Processor Time" is there any other way of using this counter and also what about the real time graph how can i display it on screen. AliAmjad (MCP)

        P 1 Reply Last reply
        0
        • A AliAmjad

          I am using the RawValue Property of "Available KBytes" Performance Counter and also used the same one for "% Processor Time" under a Timer which updates the Text of the Label after every Second But I Get always a '0' for "% Processor Time" is there any other way of using this counter and also what about the real time graph how can i display it on screen. AliAmjad (MCP)

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Do you get values when you try the performance counter properties through the actual performance counter tool in the Admin Tools?

          "Find it your bloody self - immediately!" - Dave Kreskowiak

          A 1 Reply Last reply
          0
          • P Paul Conrad

            Do you get values when you try the performance counter properties through the actual performance counter tool in the Admin Tools?

            "Find it your bloody self - immediately!" - Dave Kreskowiak

            A Offline
            A Offline
            AliAmjad
            wrote on last edited by
            #5

            Paul Conrad wrote:

            Do you get values when you try the performance counter properties through the actual performance counter tool in the Admin Tools?

            Yes i am getting values. But not on the form. I have actually created a new category and then created a copy of "% Processor Time" performance counter in it. What else should i do? AliAmjad (MCP)

            A 1 Reply Last reply
            0
            • A AliAmjad

              Paul Conrad wrote:

              Do you get values when you try the performance counter properties through the actual performance counter tool in the Admin Tools?

              Yes i am getting values. But not on the form. I have actually created a new category and then created a copy of "% Processor Time" performance counter in it. What else should i do? AliAmjad (MCP)

              A Offline
              A Offline
              AliAmjad
              wrote on last edited by
              #6

              Ok I've found the Solution for this Problem I am using the following Code now:

              Dim CPULoadCounter As New PerformanceCounter
              
              Private Sub tmrUsage\_Tick(ByVal sender As System.Object, ByVal e As system.EventArgs) Handles tmrUsage.Tick
              
                  Dim lCPULoadCounterNextValue As Single = CPULoadCounter.NextValue()
                  Me.lblCPULoad.Text = CType(lCPULoadCounterNextValue, Integer) & "%"
               
              End Sub
              Private Sub CPULoadCounterInitializer()
              
                  CPULoadCounter.CategoryName = "Processor"
                  CPULoadCounter.CounterName = "% Processor Time"
                  CPULoadCounter.InstanceName = "\_Total"
              
              End Sub
              

              Can you please tell me how can i get the Total Physical RAM Size in VB.NET? AliAmjad (MCP)

              A 1 Reply Last reply
              0
              • A AliAmjad

                Ok I've found the Solution for this Problem I am using the following Code now:

                Dim CPULoadCounter As New PerformanceCounter
                
                Private Sub tmrUsage\_Tick(ByVal sender As System.Object, ByVal e As system.EventArgs) Handles tmrUsage.Tick
                
                    Dim lCPULoadCounterNextValue As Single = CPULoadCounter.NextValue()
                    Me.lblCPULoad.Text = CType(lCPULoadCounterNextValue, Integer) & "%"
                 
                End Sub
                Private Sub CPULoadCounterInitializer()
                
                    CPULoadCounter.CategoryName = "Processor"
                    CPULoadCounter.CounterName = "% Processor Time"
                    CPULoadCounter.InstanceName = "\_Total"
                
                End Sub
                

                Can you please tell me how can i get the Total Physical RAM Size in VB.NET? AliAmjad (MCP)

                A Offline
                A Offline
                AliAmjad
                wrote on last edited by
                #7

                AliAmjad wrote:

                Can you please tell me how can i get the Total Physical RAM Size in VB.NET

                I have found its solution too :laugh: here it is:

                My.Computer.Info.TotalPhysicalMemory

                Thanks man for your cooperation ! AliAmjad (MCP)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups