Exemplo n.º 1
0
    public void RunProcess(string command, string arguments, string workDir,bool captureOutput,EventHandler exitHandler)
    {
        ProcessWrapper pw = new ProcessWrapper();
        if (captureOutput)
            pw =MainClass.ProcessService.StartProcess(command, arguments, workDir, ProcessOutputChange, ProcessErrorChange);
        else
            pw =MainClass.ProcessService.StartProcess(command, arguments, workDir, ProcessOutputNoChange, ProcessOutputNoChange);

        pw.Exited += exitHandler;
    }
Exemplo n.º 2
0
        public ProcessWrapper StartProcess(ProcessStartInfo startInfo, ProcessEventHandler outputStreamChanged, ProcessEventHandler errorStreamChanged, EventHandler exited)
        {
            if (startInfo == null)
                throw new ArgumentException ("startInfo");

            ProcessWrapper p = new ProcessWrapper();

            if (outputStreamChanged != null) {
                p.OutputStreamChanged += outputStreamChanged;
            }

            if (errorStreamChanged != null)
                p.ErrorStreamChanged += errorStreamChanged;

            startInfo.CreateNoWindow = true;
            p.StartInfo = startInfo;
            ProcessEnvironmentVariableOverrides (p.StartInfo);

            // FIXME: the bug is long gone, but removing the hacks in ProcessWrapper w/o bugs will be tricky
            // WORKAROUND for "Bug 410743 - wapi leak in System.Diagnostic.Process"
            // Process leaks when an exit event is registered
            // instead we use another thread to monitor I/O and wait for exit
            // if (exited != null)
            // 	p.Exited += exited;
            // p.EnableRaisingEvents = true;

            if (exited != null) {
            //	MonoDevelop.Core.OperationHandler handler = null;
            //	handler = delegate (MonoDevelop.Core.IAsyncOperation op) {
            //		op.Completed -= handler;
            //		exited (p, EventArgs.Empty);
            //	};
            //	((MonoDevelop.Core.IAsyncOperation)p).Completed += handler;
            }

            //Counters.ProcessesStarted++;

            p.Start ();
            return p;
        }
Exemplo n.º 3
0
    public void RunEmulator(string command, string arguments, string workDir, ProcessEventHandler pve)
    {
        this.ProcessOutput.Clear();
        ProcessWrapper pw = new ProcessWrapper();

        if (pve != null){
            pw = MainClass.ProcessService.StartProcess(command, arguments, workDir, pve, pve);
        }
        else{
            pw = MainClass.ProcessService.StartProcess(command, arguments, workDir, ProcessOutputChange, ProcessErrorChange);
        }

        //VRATIT SPET
        //runningEmulator = true;
        runningEmulator = false;

        pw.Exited += delegate(object sender, EventArgs e) {
            Console.WriteLine("Emulator exit");
            runningEmulator = false;
            if (pve != null)
                pve(null, " ");
        };
    }