bahan:
- 1 listview dengan 3 headcolumn, column1 ganti text menjadi Nama, column2 menjadi PID dan column ke 3 menjadi Memory
- StatusStrip dengan menu StatusLabel dalam hal ini yang saya gunakan StatusLabel3
- 1 button dan 2 Timer
Kemudian pada tab CPU Performance komponen tambahannya adalah:
- 2 Groupbox
- 8 label
- 2 progressbar
Selanjutnya klik 2 kali form yang sudah dibuat, hapus semua kode dan masukkan kode dibawah ini:
Public Class Form1Maka setelah di Run akan menghasilkan karya seperti 2 gambar ini:
Dim pro As Process
Dim idih As ListViewItem
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each prog As ListViewItem In ListView1.SelectedItems
MsgBox("Anda akan menghentikan proses " & prog.SubItems(0).Text)
System.Diagnostics.Process.GetProcessById(prog.SubItems(1).Text).Kill()
Timer1.Enabled = True
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ListView1.Items.Clear()
For Each Me.pro In Process.GetProcesses
idih = ListView1.Items.Add(pro.ProcessName)
idih.SubItems.Add(pro.Id)
idih.SubItems.Add(Math.Round(pro.PrivateMemorySize64 / 1024))
ToolStripStatusLabel3.Text = "Jumlah Proses: " & ListView1.Items.Count
Next
Timer1.Enabled = False
End Sub
Dim proses As New PerformanceCounter
Dim pros As New PerformanceCounter
Dim prose As New PerformanceCounter
Dim thr As New PerformanceCounter
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
proses.CategoryName = "Processor"
proses.CounterName = "% Processor Time"
proses.InstanceName = "_Total"
ProgressBar1.Value = proses.NextValue
Label5.Text = ProgressBar1.Value & " %"
Label6.Text = ProgressBar2.Value & " %"
pros.CategoryName = "Memory"
pros.CounterName = "% Committed Bytes In Use"
ProgressBar2.Value = pros.NextValue
prose.CategoryName = "Process"
prose.CounterName = "Handle Count"
prose.InstanceName = "_Total"
thr.CategoryName = "Process"
thr.CounterName = "Thread Count"
thr.InstanceName = "_Total"
Label8.Text = prose.NextValue
Label7.Text = thr.NextValue
End Sub
End Class
No comments:
Post a Comment