Exemplo n.º 1
0
        public static void guardprocess(string path, string Arguments, bool buseshellexecute = true)
        {
            Process      p1  = Utility.CommandRun(path, Arguments, buseshellexecute);
            ProcessInfor pi1 = new ProcessInfor();

            pi1.mprocess  = p1;
            pi1.apppath   = path;
            pi1.parameter = Arguments;
            if (p1 != null)
            {
                Thread newThread = new Thread(Program.DoWork);
                newThread.Start(pi1);
            }
        }
Exemplo n.º 2
0
        public static void DoWork(object p)
        {
            ProcessInfor p1 = (ProcessInfor)p;

            while (true)
            {
                Thread.Sleep(500);
                bool b = p1.mprocess.HasExited;
                if (b)
                {
                    Process      p2  = Utility.CommandRun(p1.apppath, p1.parameter);
                    ProcessInfor pi1 = new ProcessInfor();
                    pi1.mprocess  = p2;
                    pi1.apppath   = p1.apppath;
                    pi1.parameter = p1.parameter;
                    if (p2 != null)
                    {
                        Thread newThread = new Thread(Program.DoWork);
                        newThread.Start(pi1);
                    }
                    break;
                }
            }
        }