Beispiel #1
0
        private void updateProcessesListBox()
        {
            List <Process> current_processes = Process.GetProcesses().ToList();

            current_processes.Sort((Process a, Process b) => string.Compare(a.ProcessName, b.ProcessName));
            for (int h = 0; h < current_processes.Count; h++)
            {
                if (this.stopped_process.ContainsKey(current_processes[h].Id))
                {
                    continue;
                }

                if (TaskManagerForm.processes.ContainsKey(current_processes[h].Id))
                {
                    //the process already existed
                    if (TaskManagerForm.processes[current_processes[h].Id].Status == PROCESS_STATUS.Terminated)
                    {
                        this.stopped_process[current_processes[h].Id] = TaskManagerForm.processes[current_processes[h].Id];
                        this.stoppedProcess.Invoke(new Action(() => this.stoppedProcess.Items.Add($"{current_processes[h].Id}: {this.stopped_process[current_processes[h].Id].Name}")));
                        this.ProcessList.Invoke(this.removeFromListBox, this.ProcessList, $"{current_processes[h].Id}: {this.stopped_process[current_processes[h].Id].Name}");
                        continue;
                    }
                }
                else
                {
                    //the process is new
                    WinTask winTask = new WinTask(current_processes[h]);
                    TaskManagerForm.processes[winTask.PID] = winTask;
                    this.ProcessList.Invoke(this.addToListBox, this.ProcessList, $"{current_processes[h].Id}: {current_processes[h].ProcessName}");
                }
            }
        }
Beispiel #2
0
        private void ProcessList_Click(object sender, EventArgs e)
        {
            string string_pid = (string)this.ProcessList.SelectedItem;

            string_pid            = string_pid.Split(':')[0];
            this.selected_process = TaskManagerForm.processes[Convert.ToInt32(string_pid)];
            this.updateCurrentProcessInfo();
        }
Beispiel #3
0
        private void create_process_btn_Click(object sender, EventArgs e)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();
            Process          process   = new Process();

            startInfo.FileName         = "python.exe";
            startInfo.UseShellExecute  = false;
            startInfo.Arguments        = "D:\\ElMar\\Documents\\SoftwareProjects\\Respaldos\\createBackup.py";
            startInfo.WorkingDirectory = "D:\\ElMar\\Documents\\SoftwareProjects\\Respaldos\\";
            process.StartInfo          = startInfo;
            process.Start();
            this.selected_process = new WinTask(process);
            TaskManagerForm.processes[process.Id] = this.selected_process;
            this.updateCurrentProcessInfo();
        }
Beispiel #4
0
 private void terminarToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.selected_process != null)
     {
         string process_name = this.selected_process.RealName;
         foreach (Process p in Process.GetProcessesByName(process_name))
         {
             this.stopped_process[p.Id] = this.selected_process;
             p.CloseMainWindow();
             p.Close();
         }
         this.selected_process = null;
         this.current_process_status.Invoke(this.changeLabelText, this.current_process_status, "Status: proceso terminado");
     }
     else
     {
         MessageBox.Show("Seleccione un proceso no sea especialito :3");
     }
 }