Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to retrieve a list of ongoing processes in a C# GUI application is to use the Process class in the System.Diagnostics namespace. Here is an example code snippet:

using System.Diagnostics;

// retrieve a list of ongoing processes
Process[] processes = Process.GetProcesses();

// display the list in a ListBox control
foreach (Process process in processes)
{
    listBox1.Items.Add(process.ProcessName);
}

Note that this code retrieves all ongoing processes in the system, not just those associated with the current application. To filter the list to only include processes associated with the current application, you can use the GetCurrentProcess() method of the Process class:

// retrieve a list of ongoing processes associated with the current application
Process[] processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);

// display the list in a ListBox control
foreach (Process process in processes)
{
    listBox1.Items.Add(process.ProcessName);
}