---
title: "System Process in C#"  
description: "What is System Process?  The Process component is useful to obtain the list of the processes that are running on the system.With the help of Process c"  
author: "Sachindra Singh"  
published: 2011-02-11  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/442/system-process-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 3 minutes  

---

# System Process in C#

What is System Process?\

The Process component is useful to obtain the list of the processes that are running on the system.With the help of Process component tool we can manage starting, stopping, controlling, and monitoring applications. The System.Diagnostics namespace contains functions that allow you to manage processes, threads, eventlogs and performance information. In this Demonstration I am trying to show how we can obtain list of process that are currently open and close.

##### Code:

```
class Demonstration_Of_Process    {         public voidCheck(Process[] pr)//Creating check function with parameter         {             int flag=0;//creating int variable initializing from 0             Process[]  current=pr;//creating array(current) of process and initializing from pr variable that contain list of processing that are running             Process[]  previous=pr;//creating array(previous) of process and initializing from pr variable that contain list of processing that are running             while (true)//while loop will be execute inifinte time to obtain list of process that are running on the system            {                current=Process.GetProcesses();//current variable containing the list of the application that are running                 if (current.Length> previous.Length)//checking condition current length of process is greater than previous length of process or not                 {                     foreach (Process cur incurrent)//loop executing                      {                         if (flag==0)//checking condition                        {                             foreach (Process temp inprevious)//loop executing                             {                                 if (temp.ProcessName==cur.ProcessName)// condition checking that application is runing or not                                 {                                    flag =1;//variable flag initializing from 1                                     break;// current loop will be terminate if application exist in the process                                      }                           }                                                }                        if (flag==0)//checking condition                        {                             Console.WriteLine(" Start-->"+cur.ProcessName);//message will be show on command window                        }                        flag =0;//flag initializing from 0                      }                }                 else                {                     if (current.Length< previous.Length)//checking condition if any application has closed                     {                        foreach (Processcurinprevious)//loop executing of pervious process                        {                             foreach (Process temp incurrent)//loop executing of current process                                {                                     if (temp.ProcessName==cur.ProcessName)//condition checking  that application which application has terminated                                     {                                        flag =1;//variable flag initializing from 1                                         break;//current loop will be terminate if application exist in the process                                             }                                }                                   if (flag==0)//checking condition                            {                                 Console.WriteLine(" Close -->"+cur.ProcessName);//message will be show on command window                            }                            flag =0;//flag initializing from 0                          }                    }                }                previous=current;//copying all list of process in previous variable            }          }         public staticvoidMain()         {            Demonstration_Of_Process dof= new Demonstration_Of_Process();//creating object of the class             Process[]  pp= Process.GetProcesses();//creating process array and store list of application in pp variable from GetProcesses() method            dof.Check(pp);//calling parametrize function and passing value pp         }    }
```

After run this Demonstration if I open Notepad application the window will display message “Start->notepad” it means Notepad has open as shown below:

##### Output

![System Process](https://www.mindstick.com/mindstickarticle/ae183984-7fed-49d3-b7d1-afddf6b71d5e/images/64113840-3699-43e1-9f3f-60de0fdda8cf.png)

If I close Notepad, the command window will show message “**Close****ànotepad”** it means application has closed as shown below:

##### Output

![System Process](https://www.mindstick.com/mindstickarticle/ae183984-7fed-49d3-b7d1-afddf6b71d5e/images/04692cc2-a41b-40ea-ac8e-001f6f7d9ee8.png)

\

---

Original Source: https://www.mindstick.com/articles/442/system-process-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
