Running Process List C# with Example



Running Process List C# with Example

 using System;
using System.Linq;
using System.Diagnostics;

namespace CSharpMultiThreading
{
    class MainMethodClass
    {
        static void Main()
        {
			ListAllRunningProcesses();
        }
    	
		static void ListAllRunningProcesses()
		{
			// Get all the processes on the local machine, ordered by PID.
			var runningProcs = from proc in Process.GetProcesses(".") orderby proc.Id select proc;
			
			// Print out PID and name of each process.
			foreach(var p in runningProcs)
			{
				string info = string.Format("-> PID: {0}\tName: {1}", p.Id, p.ProcessName);
				Console.WriteLine(info);
			}
		}
	}
}
 

0 Comment's

Comment Form