Click here to Skip to main content
13,088,507 members (55,969 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 30 Aug 2007

My TaskManager

, , 30 Aug 2007
Rate this:
Please Sign up or sign in to vote.
A task manager with additional functionality
Screenshot - task.jpg


I know that on Code Project there are a lot of process managers programmed by brilliant programmers. But I need some more functionally in these process managers. Therefore I created my own task manager.


Why I created this process manager, the reason is that sometimes we need to release our memory in just a short time. It takes time to select unnecessary processes from the Windows task managers and kill them one by one. While running some games or any other programs that require high RAM when you have shortage of RAM, this poses a problem. You'll want to use the RAM by only system processes and your favorite processes.

Point of Interest

You can create a list of programs and after opening the program MyTaskManager.exe, you will press the button "kill list processes." All of the process you add to the kill list will kill automatically. One thing I keep in mind with this program is that if there is some precious process, like system processes and maybe some other processes, you may not want to stop them at any cost. You must therefore add them to the except list. This process will never kill, although you add it in the kill list or attempt to kill it by mistake.

How It Works

It also reads the files Kill_List.xml and Except_List.xml. Keep the information while running the program. You can add a program to the kill list by right clicking on the process to add and then adding it to the list. The kill list is the list that the user will kill the processes with by clicking the button "kill list processes." The except list is the list of processes that you want to not kill at any cost, whether you add them to the kill list by accident or select for them for killing. It works like Task Manager, but I added some things that are following, through which you can get some extra work done.

Screenshot - Menue.jpg

After right clicking on the process, you can choose one of four operations for the selected process.

  1. You can open the folder containing the process.
  2. You can kill the selected process if it is not in the except list.
  3. You can add it to the except list.
  4. You can add it to the kill list.
Screenshot - Kill_button.jpgScreenshot - more_buttons.jpg

By clicking the kill list, it will kill all the processes that you've added to the kill list. View kill list and view except list to get data from the files Kill_List.xml and Except_List.xml and to view your processes in both categories. "New Task" just works like "Run" in the Windows menu.

Code Overview

In this program, I get all processes of the system through the function GetProcesses.

string[] Mem_Usage = new string[100];
string[] ProcessNames = new string[100];
process = Process.GetProcesses();
noOfProcess = 0;
int i = 0;
ListViewItem lvi = new ListViewItem();
foreach (Process pro in process)
    String pathx = "";
    //get path of the procees 
        pathx = pro.Modules[0].FileName;
    //remove unnecessory special characters 
        pathx = pathx.Replace("\\??\\", "");
    // add whole path into string array
        path[i] = pathx.ToString();
    Catch (Win32Exception)
        path[i] = "";
    // get the name of the process
    ProcessNames[i] = pro.ProcessName;
    // get the amount of ram using process
    Mem_Usage[i] = Convert.ToString(pro.PagedMemorySize64);
    // add process names into list view item
    lvi = new ListViewItem(ProcessNames[i]);
    // add momory usage by the process in to list item item as sub //item
    // add list view item in to list view
    // count numbers of process

After getting processes, we use one function, ReadXmlFile, for both the Except_List.xml and Kill_List.xml files.

public void ReadXmlFile(string filename)
        // name of the file to read
        reader = new XmlTextReader(filename);//,new 
        // it should handl whit space during reading
        reader.WhitespaceHandling = System.Xml.WhitespaceHandling.None;
        // define the string Process in Kill list
        PInKill_List = new string[100];
        bool bEnableProcessNamesContent = false;
        bool bEnableProcessContent = false;
        int i = 0;
        // read upto end
        while (reader.Read())
            // check the node of the reading data
            switch (reader.NodeType)
                //is it a Element of the node
                case System.Xml.XmlNodeType.Element:
                    bEnableProcessNamesContent = 
                       (reader.Name == "PorecessNames");
                    bEnableProcessContent = (reader.Name == "Process");
                 // check for text in the node
                 case System.Xml.XmlNodeType.Text:
                     // add the value into text box
                     txtbox.Text += reader.Value + "\n";
                     PInKill_List[i] = reader.Value;
                     PInKill_List[i] = PInKill_List[i].TrimEnd('\r');
                     if (check)
            check = false;
        } // end of try 
        catch (Exception)


I use the timer event to check processes after a specific time.

public System.Timers.Timer timer = new System.Timers.Timer(4000);

The default time is 4 seconds, but the user can change the time of the refresh rate from 1 second up to 8 seconds. After the timer event call, I call the function Check4Process, which will compare the number of old processes with the number of new process. If it is the same, then leave it. If not, then the GetProcesss function will call again and add it to the list view control.

private void Check4Processes()
    Process[] gPro = Process.GetProcesses();
    int Numpro = 0;
    string[] names = new string[100];
    string[] mem = new string[100];
    foreach (Process pro in gPro)
        names[Numpro] = pro.ProcessName;
        mem[Numpro] = Convert.ToString(pro.PagedMemorySize64);
    // if nuber of process are decrease 
    if (Numpro < noOfProcess)
        //no of process are decreased
    // if new process is added
    if (Numpro > noOfProcess)
        // no of Process are increased

In Kill_List, the function Check_Porcess_In_ExceptList is used when we are going to kill any process. We check whether it exists in the except list or not and return the bool value.

public bool Check_Process_in_ExceptList(string toCheck, Kill_List Except_Obj)
    //Kill_List Except_Obj = new Kill_List("Except_List");
    Except_Obj.ReadXmlFile("Kill List.xml");
    string pNames = Except_Obj.txtbox.Text;
    bool found =false;
    string[] SingleProcessName = ConvertStringToStringArray(pNames);
    foreach(string str in SingleProcessName)
        //found = (toCheck == str ? true : false);
        if(toCheck ==str)
            found = true;
    return found;


  • 30 August, 2007 -- Original version posted


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Authors

Naveed Khan
Pakistan Pakistan
No Biography provided

Software Developer
Pakistan Pakistan
I am working as Software Developer in

You may also be interested in...

Comments and Discussions

QuestionResult does not match that from the system task manager Pin
LeoLiu_7-Jun-11 19:43
memberLeoLiu_7-Jun-11 19:43 
GeneralMy vote of 1 Pin
karim aslam5-Feb-11 22:45
memberkarim aslam5-Feb-11 22:45 
GeneralQuestion: Task manager "Except" list C# function to Pin
jlkdaslkfjd11-Sep-10 22:17
memberjlkdaslkfjd11-Sep-10 22:17 
Questionrun... [modified] Pin
moncayos5-May-09 15:04
membermoncayos5-May-09 15:04 
AnswerRe: run... Pin
Naveed khan nido6-May-09 17:30
memberNaveed khan nido6-May-09 17:30 
Generaladvice Pin
y_12345678_913-Sep-08 6:47
membery_12345678_913-Sep-08 6:47 
GeneralMy Task Manager Pin
ShowMeHow20-Jun-08 9:09
memberShowMeHow20-Jun-08 9:09 
GeneralRe: My Task Manager Pin
EliottA2-Feb-09 9:19
memberEliottA2-Feb-09 9:19 
Generala comment by Miszou Pin
Sean Ewington4-Sep-07 3:36
adminSean Ewington4-Sep-07 3:36 
Questionhow to start demo Pin
dan o3-Sep-07 21:41
memberdan o3-Sep-07 21:41 
AnswerRe: how to start demo Pin
cdgwinn4-Sep-07 16:58
membercdgwinn4-Sep-07 16:58 
GeneralRe: how to start demo Pin
dan o4-Sep-07 21:35
memberdan o4-Sep-07 21:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170813.1 | Last Updated 30 Aug 2007
Article Copyright 2007 by Naveed Khan, Naveed727
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid