Question Making a Task Manager clone


Sep 14, 2020
Programming Experience

I'm new to this forum and I'm self-taught in writing small programs and honing my skills with programming with .NET for Windows for a while now. I've been trying to make a clone of the classic old-style task manager found in older versions of Windows and to build this clone and mimic the behaviours of the Windows Task Manager in Visual Studio 2015 with the .NET framework version 3.0.

This clone of old-style task manager, like in Windows; is also found in open-source projects such as the
Wine Project for UNIX-like systems and ReactOS, I thought I'd throw that in as a reference to what my end-goal is and release it under the GNU General Public License: Version 2 software EULA on My Github account.

Anyway, onto the problem at hand...

Displaying a list of processes in a ListView object (Sorted as Columned items in 'processes' tab):
[FONT=courier new]Private Sub Form1_load(sender As Object, e As EventArgs) Handles MyBase.load
    Dim Process As New Process()
        Dim Count As Integer = 0
            For Each Process In Process.GetProcesses(My.Computer.Name)
            On Error Resume Next
        ListView1.Items(Count).SubItems.Add(FormatNumber(Math.Round(Process.PrivateMemorySize64 / 1024), 0))
        Count += 1
    ToolStripStatusLabel1.Text = "Processes: " & ListView1.Items.Count
End Sub[/FONT]

As for the processes themselves, I'd like to see the file extensions in all of them and their icons too and if an application doesn't have an icon, I'd consider using a generic blank icon from my projects 'resources' folder.

Ending an application Process:
[FONT=courier new]Private Sub Button1_Click (click sender As Object, e as EventArgs) Handles Button1.Click
    For Each Process As ListViewItem In Form1.ListView2.SelectedItems
    Form1.Form1_Load(Nothing, Nothing)
End Sub[/FONT]

The code for terminating a process doesn't work when it should be dead in the water, sorta speak; until reviving it again at will by the user or the system object managing it.

In first code you have ListView1, in second ListView2. You should give the controls a name other than 1 and 2.

Some other tips:
  • You should call CloseMainWindow first, and only if that returns false call Kill.
  • Count variable is not needed, .Items.Add method returns the item created so you can refer to that when adding subitems. Assign GetProcesses to a variable, use it both for loop and to get count for label text. (CountStatusLabel.Text = processes.Count)
  • "On Error Resume Next" is bad error handling, use Try-Catch instead. Specifically the StartTime may throw Win32Exception with access denied for some processes.
  • ListView.BeginUpdate/EndUpdate is recommended when adding lots of data to the control. It will prevent redrawing of the control during updating.

Latest posts