?
?BOT
Why is the following code so slow? I have a listView that must refresh it's
processes data every 3 seconds. However, this sometimes goes beyond 5
seconds and crashes the application. I have tries multi-threading, also
ListView.BeginUpdate + EndUpdate(), but the code is sooo slow. Try it for
yourself:
Public Sub UpdateData()
On Error Resume Next
Me.ListView1.Clear()
For Each process As System.Diagnostics.Process In
Me.Process1.GetProcesses()
Dim ListItem As New ListViewItem(process.ProcessName)
With ListItem
.SubItems.Add(process.MainModule.FileName)
.SubItems.Add(process.TotalProcessorTime.ToString())
.SubItems.Add(process.PriorityClass.ToString())
.SubItems.Add(process.PagedMemorySize)
.SubItems.Add(process.NonpagedSystemMemorySize)
.SubItems.Add(process.Modules.Count)
.SubItems.Add(process.MainModule.FileVersionInfo.CompanyName)
End With
Me.ListView1.Items.Add(ListItem)
Next
End Sub
Any help is greatly appreciated.
processes data every 3 seconds. However, this sometimes goes beyond 5
seconds and crashes the application. I have tries multi-threading, also
ListView.BeginUpdate + EndUpdate(), but the code is sooo slow. Try it for
yourself:
Public Sub UpdateData()
On Error Resume Next
Me.ListView1.Clear()
For Each process As System.Diagnostics.Process In
Me.Process1.GetProcesses()
Dim ListItem As New ListViewItem(process.ProcessName)
With ListItem
.SubItems.Add(process.MainModule.FileName)
.SubItems.Add(process.TotalProcessorTime.ToString())
.SubItems.Add(process.PriorityClass.ToString())
.SubItems.Add(process.PagedMemorySize)
.SubItems.Add(process.NonpagedSystemMemorySize)
.SubItems.Add(process.Modules.Count)
.SubItems.Add(process.MainModule.FileVersionInfo.CompanyName)
End With
Me.ListView1.Items.Add(ListItem)
Next
End Sub
Any help is greatly appreciated.