Dim myProcesses() As Process = Process.GetProcesses
Dim myProcess As Process
For Each myProcess In myProcesses
If (myProcess.ProcessName.ToLower = "buggyprocess") Then
myProcess.Kill()
End If
Next
'and also
PC.CategoryName = "Processor"
PC.CounterName = "% Processor Time"
PC.InstanceName = "_Total"
MessageBox.Show(PC.NextValue().ToString())
'and also
'-- Declare Private Member
Private mPerformanceCounter 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
lvCPU.Items.Clear()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
lvCPU.Items.Add(CInt(mPerformanceCounter.NextValue()) & "%")
lvCPU.SelectedIndex = lvCPU.Items.Count - 1
End Sub
|