Click here to Skip to main content
15,887,027 members
Home / Discussions / Visual Basic
   

Visual Basic

 
JokeRe: Just a friendly reminder... Pin
Paul Conrad14-May-07 9:14
professionalPaul Conrad14-May-07 9:14 
GeneralRe: Just a friendly reminder... Pin
Dave Kreskowiak14-May-07 9:47
mveDave Kreskowiak14-May-07 9:47 
GeneralRe: Just a friendly reminder... Pin
Paul Conrad14-May-07 9:53
professionalPaul Conrad14-May-07 9:53 
QuestionHow to filter data readed from code bar reader to datagrid Pin
Mr. Wonderful14-May-07 8:14
Mr. Wonderful14-May-07 8:14 
AnswerRe: How to filter data readed from code bar reader to datagrid Pin
Dave Kreskowiak14-May-07 8:50
mveDave Kreskowiak14-May-07 8:50 
GeneralRe: How to filter data readed from code bar reader to datagrid Pin
Mr. Wonderful15-May-07 7:09
Mr. Wonderful15-May-07 7:09 
QuestionHow to see CPU use (%) Pin
Zaegra14-May-07 8:12
Zaegra14-May-07 8:12 
AnswerRe: How to see CPU use (%) Pin
MatrixCoder14-May-07 8:23
MatrixCoder14-May-07 8:23 
I found this example awhile ago, and it's still the only way that I've found to read CPU usage that actually works.

Dim eIdle As Int64
Dim eKernel As Int64
Dim eUser As Int64
Dim sIdle As Int64
Dim sKernel As Int64
Dim sUser As Int64
Dim cIdle As Int64
Dim cKernel As Int64
Dim cUser As Int64
Dim systemTime As Int32
Dim totalCpuUsage As Single 'Long 'Int64

Public Declare Auto Function GetSystemTimes Lib "kernel32.dll" (ByRef idleTime As Int64, ByRef kernelTime As Int64, ByRef userTime As Int64) As Boolean
Dim updateSpeed As Integer = 500

Public Sub GetCPUUsage()

'Retrieve the Times values before starting the delay.
GetSystemTimes(sIdle, sKernel, sUser)

'The delay for how often to check and update the cpu usage values.
Threading.Thread.Sleep(updateSpeed)

'Retrieve the Times values after the Delay.
GetSystemTimes(eIdle, eKernel, eUser)

'Get the values calculated between the starting and ending Times values.
cIdle = (eIdle - sIdle)
cKernel = (eKernel - sKernel)
cUser = (eUser - sUser)

'Calculate the total system time. Which is Kernel and User time together.
systemTime = (cKernel + cUser)

'Simply check if the rounded option is true or not and display the usage value.
totalCpuUsage = (systemTime - cIdle) * (100) \ (systemTime)

'System.Windows.Forms.Application.DoEvents()
CPUUseLbl.Text = "CPU Usage: " & totalCpuUsage.ToString & "%"
Dim Ok As Integer = 0
        
End Sub

Hope this helps.




Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.

GeneralRe: How to see CPU use (%) [modified] Pin
Dave Kreskowiak14-May-07 8:40
mveDave Kreskowiak14-May-07 8:40 
GeneralRe: How to see CPU use (%) Pin
Paul Conrad14-May-07 8:53
professionalPaul Conrad14-May-07 8:53 
GeneralRe: How to see CPU use (%) Pin
Zaegra15-May-07 3:14
Zaegra15-May-07 3:14 
AnswerRe: How to see CPU use (%) Pin
Dave Kreskowiak14-May-07 8:44
mveDave Kreskowiak14-May-07 8:44 
QuestionTimer control running in the background Pin
steve_rm14-May-07 8:05
steve_rm14-May-07 8:05 
AnswerRe: Timer control running in the background Pin
SimulationofSai14-May-07 9:36
SimulationofSai14-May-07 9:36 
GeneralRe: Timer control running in the background Pin
steve_rm14-May-07 15:52
steve_rm14-May-07 15:52 
GeneralRe: Timer control running in the background Pin
Dave Kreskowiak14-May-07 16:36
mveDave Kreskowiak14-May-07 16:36 
QuestionHelp for Packet drop/pass Pin
Sunil KC14-May-07 7:34
Sunil KC14-May-07 7:34 
AnswerRe: Help for Packet drop/pass Pin
Dave Kreskowiak14-May-07 8:38
mveDave Kreskowiak14-May-07 8:38 
QuestionHow to Hide Members of Base Class Pin
Probeer Das14-May-07 7:16
Probeer Das14-May-07 7:16 
AnswerRe: How to Hide Members of Base Class Pin
nlarson1114-May-07 8:30
nlarson1114-May-07 8:30 
GeneralRe: How to Hide Members of Base Class Pin
Probeer Das15-May-07 3:21
Probeer Das15-May-07 3:21 
QuestionSetting value for resources Pin
ctlqt1214-May-07 5:45
ctlqt1214-May-07 5:45 
AnswerRe: Setting value for resources Pin
Dave Kreskowiak14-May-07 8:36
mveDave Kreskowiak14-May-07 8:36 
QuestionStretchBlt to a PictureBox ? Pin
Beginner_HC14-May-07 4:24
Beginner_HC14-May-07 4:24 
AnswerRe: StretchBlt to a PictureBox ? Pin
Dave Kreskowiak14-May-07 4:43
mveDave Kreskowiak14-May-07 4:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.