VB.NET Running Process List

The Process component is a powerful tool for managing applications, providing functionalities to start, stop, control, and monitor them. It is a part of the System.Diagnostics namespace, which offers a range of classes for interacting with system processes, event logs, and performance counters.

Imports System.Diagnostics

In addition to retrieving lists of running processes or viewing information about the process that currently has access to the processor, you can get detailed knowledge of process threads and modules both through the Process class itself.

Dim plist() As Process = Process.GetProcesses()

Process component

With the Process component, developers can perform various operations related to system processes. This includes retrieving lists of running processes, accessing detailed information about a specific process, controlling its execution, and monitoring its performance.

In addition to obtaining general information about a process, such as its ID, name, and resource usage, the Process class also provides insights into process threads and modules. Threads represent individual units of execution within a process, and modules are the loaded libraries or code files associated with the process. By utilizing the Process class, developers can access detailed knowledge of threads and modules, enabling them to gain a deeper understanding of the process's behavior and structure.

The following VB.NET program shows how to retrieve the process name and Memory Allocation of each process from a running system. Drag and drop a Button and ListBox control on your VB.NET Form, and copy and paste the following source code on button click event.

Full Source VB.NET
Imports System.Diagnostics Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim plist() As Process = Process.GetProcesses() For Each prs As Process In plist ListBox1.Items.Add(prs.ProcessName + " (" + prs.PrivateMemorySize64.ToString() + ")") Next End Sub End Class

Conclusion

To optimize performance and minimize unnecessary resource consumption, the Process component intelligently caches information. When information about one member of a group (e.g., process threads or modules) is obtained, the values for the other properties in that group are cached. This means that subsequent accesses to those properties will not trigger new information retrieval unless the Refresh method is explicitly called. This caching mechanism ensures efficient access to process-related information without unnecessary overhead.