I am trying to populate a listbox with a list of running processes, so my users can select the process they wish to monitor.
I have tried the following, along with lots of variations of it and I just can't get it to work.
foreach(Process p in Process.GetProcesses())
{
listBox1.Items.Add(p.ProcessName);
}
It doesn't do anything, however, I have seen others saying it worked for them. Any ideas?
Have you tried running on a timer or thread?
OR Insert the code below into the button click event.
Process[] allProc = Process.GetProcesses();
foreach (Process p in allProc)
{
listBox1.Items.Add(p.ProcessName);
}