+92 332 4229 857 99ProjectIdeas@Gmail.com

Making Your Own Task Manager (C#.net)




The following code shows you how to make your own task manager, all the processes are in listbox and you can end them also... or also you can add a new task as well.








using System.Diagnostics;

public void frmTaskManager_Load(System.Object sender, System.EventArgs e)
{
   foreach (Process process in Process.GetProcesses())
   {
       listBoxProcesses.Items.Add(process.ProcessName);
   }
}

public void btnEndTask_Click(System.Object sender, System.EventArgs e)
{
  try
     {
foreach (Process process in Process.GetProcessesByName(listBoxProcesses.SelectedItem.ToString()))
       {
       
      DialogResult dr = MessageBox.Show("You Want To End This Process?", "Decision?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     
      if (dr == DialogResult.Yes)
       {
              process.Kill();
              int index = listBoxProcesses.SelectedIndex;
              listBoxProcesses.Items.RemoveAt(index);
       }
       else
       {
              return;
       }
     }
   }
    catch (System.Exception ex)
   {
          MessageBox.Show(ex.Message);
   } 
}

public void btnNewTask_Click(object sender, EventArgs e)
        {
            Form frmNew = new frmNewTask();
            frmNew.Show();
        }

public void btnStart_Click(System.Object sender, System.EventArgs e)
 {
    try
        {
            Process.Start(txtNewTask.Text);
        }
         catch (System.Exception ex)
        {
              MessageBox.Show(ex.Message);
       }
                    
 }
             
 public void btnBrowse_Click(System.Object sender, System.EventArgs e)
 {
        OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
        OpenFileDialog1.Title = "Please Select a File";

       if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
       {
             txtNewTask.Text = OpenFileDialog1.FileName;
       }
 }


0 comments: