Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMonitor CPU usage in Visual Basic .NET
DescriptionThis example shows how to monitor CPU usage in Visual Basic .NET.
KeywordsCPU usage, CPU load, PerformanceCounter, VB.NET
CategoriesVB.NET, Windows, Software Engineering
 
This program creates a PerformanceCounter to get total processor time values. When its Timer fires, it adds a new CPU usage value to a ListBox.
 
Private m_PerformanceCounter As New _
    System.Diagnostics.PerformanceCounter( _
        "Processor", "% Processor Time", "_Total")

Private Sub btnClear_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnClear.Click
    lstCpu.Items.Clear()
End Sub

Private Sub tmrCheckCpu_Tick(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles tmrCheckCpu.Tick
    lstCpu.Items.Add(CInt(m_PerformanceCounter.NextValue()) _
        & "%")
    lstCpu.SelectedIndex = lstCpu.Items.Count - 1
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated