0

So I have to pause a process for a second and then Start the other one, So basically I have to pause and resume this processes.

Also I have to use a Stack. Have to Save the process as it's executing so I can resume it. Has to have an ID and show the Priority.

Anybody knows what I have to use?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;

namespace Práctica_2
{
    class Program
    {

            static void Main(string[] args)
            {

                Process Contador = new Process();
                Process Datos = new Process();
                Process Google = new Process();
                Process Numero = new Process();
                Process Finalizar = new Process();


                try
                {                    
                    System.Diagnostics.Process.Start("C:\\Users\\M-00\\Desktop\\Práctica 2\\Datos\\Datos\\obj\\Debug\\Datos.exe");
                    Datos.Start();
                    Thread.Sleep(250);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                try
                {
                    System.Diagnostics.Process.Start("C:\\Users\\M-00\\Desktop\\Práctica 2\\Contador\\Contador\\obj\\Debug\\Contador.exe");
                    Contador.Start();
                    Datos.WaitForExit(250);
                    Thread.Sleep(500);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                try
                {
                    System.Diagnostics.Process.Start("C:\\Users\\M-00\\Desktop\\Numeros\\Numeros\\obj\\Debug\\Numeros.exe");
                    Numero.Start();
                    Datos.WaitForExit(500);
                    Thread.Sleep(750);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
    }
  • Do you mean to say you want to pause an external application? For example, you want to pause `Datos.exe`? – Rob May 02 '16 at 23:29
  • Yeah, excatly that. Sorry I suck at expressing myself. – Marco Diez Barroso Zamudio May 02 '16 at 23:30
  • 1
    Take a look here: http://stackoverflow.com/questions/71257/suspend-process-in-c-sharp – Rob May 02 '16 at 23:31
  • I have to pause it and after the last Process it's on pause [Numeros.exe], I have to start the first one. – Marco Diez Barroso Zamudio May 02 '16 at 23:31
  • Thanks! I'll check it out! – Marco Diez Barroso Zamudio May 02 '16 at 23:32
  • Ok, I think I undertand it, bue I don't know how to implement it. – Marco Diez Barroso Zamudio May 02 '16 at 23:37
  • 1
    I'm not too sure what you mean - that link contains the complete implementation. You'd simply have to run `SuspendProcess(pid)`, and you get `pid` from the return value of `Start()` - `var proc = System.Diagnostics.ProcessProcess.Start("..."); SuspendProcess(proc.Id);` – Rob May 02 '16 at 23:42
  • Link suggested by @Rob seem to be answering part of the questions about suspending processes (so duplicate). You may want to ask separate question(s) about other aspects of the problem. Side note: if it is your homework I'd strongly recommend to check what is actually expected of you - "use stack" and native process management don't look like belonging to the same level of assignments. – Alexei Levenkov May 03 '16 at 00:15

0 Answers0