This is the code i'm using:

List<Process> processes = Process.GetProcesses().ToList();
            processes.ForEach(x => MessageBox.Show(x.ProcessName + ".exe"));

For some reason, it is looping through it, I just want it to go through the processes once.

Anybody got any help?

Your question doesn't make sense but based on the sample code I assume you want to show one message box with all of the processes? If that is the case call ShowProcessesGroup(); as shown below. ShowProcessesIndividually() is functionally identical to the code you posted.

private static void ShowProcessesIndividually()
    {
      Process[] procs = Process.GetProcesses();
      foreach (Process p in procs)
      {
        MessageBox.Show(p.ProcessName + ".exe");
      }
    }

    private static void ShowProcessesGroup()
    {
      System.Text.StringBuilder sb = new StringBuilder();
      Process[] procs = Process.GetProcesses();
      foreach (Process p in procs)
      {
        sb.AppendLine(p.ProcessName + ".exe");
      }
      MessageBox.Show(sb.ToString());
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.