コード例 #1
0
        private void RunEM2()
        {
            _process = new Process();
            _process.StartInfo.FileName       = EnvironmentInfo.GetEM2ExecutableFile();
            _process.StartInfo.Arguments     += EnvironmentInfo.EncloseByQuotes(_em2ConfigurationFile);
            _process.StartInfo.CreateNoWindow = true;

            //redirect the standard-output and standard-error of the process, to be asynchronously read by event handlers
            _process.StartInfo.UseShellExecute        = false;
            _process.StartInfo.RedirectStandardOutput = true;
            _process.StartInfo.RedirectStandardError  = true;
            _process.OutputDataReceived += new DataReceivedEventHandler(RunLogHandler);
            _process.ErrorDataReceived  += new DataReceivedEventHandler(ErrorLogHandler);

            //out-commented the following part and using a BackgroundWorker instead, as the callback function works from the processes thread
            //thus accessing the RunInfo-window fails
            //set event handler to recognise termination
            //_process.EnableRaisingEvents = true;
            //_process.Exited += new EventHandler(ExitedHandler);

            //start the process and start the asynchronous read of the output
            if (!_process.Start())
            {
                lock (_errorLogLock) { _errorLog.Add("Failed to start model run."); } //should not happen
                _runManager.HandleRunExited(this);
            }

            _process.BeginOutputReadLine();
            _process.BeginErrorReadLine();
            _processStatusAdditionalInfo = string.Format("{0:T}", _process.StartTime) + " - ";

            _process.WaitForExit();
        }
コード例 #2
0
        private bool EM2_Run(SystemBackgroundWorker sbw)
        {
            sbw.process = new Process();
            sbw.process.StartInfo.FileName   = EnvironmentInfo.GetEM2ExecutableFile();
            sbw.process.StartInfo.Arguments += EnvironmentInfo.EncloseByQuotes(sbw.config.First().Key);

            sbw.process.StartInfo.CreateNoWindow        = true;
            sbw.process.StartInfo.UseShellExecute       = false;
            sbw.process.StartInfo.RedirectStandardError = true;
            sbw.process.ErrorDataReceived += (t1, t2) => { if (t2.Data != null && t2.Data != "")
                                                           {
                                                               sbw.em2_hasErrorFile = true;
                                                           }
            };

            sbw.process.Start();
            sbw.process.BeginErrorReadLine();
            sbw.process.WaitForExit();
            return(sbw.process.ExitCode == 1);
        }
コード例 #3
0
        private void RunEM3_Exe(string configurationFile)
        {
            _process = new Process();
            EnvironmentInfo.GetEM3ExecutableCallerInfo(_process.StartInfo);
            _process.StartInfo.Arguments += "UI_RUNTOOL_CALL ";
            _process.StartInfo.Arguments += EnvironmentInfo.EncloseByQuotes(_em2ConfigurationFile);

            _process.StartInfo.CreateNoWindow         = true;
            _process.StartInfo.UseShellExecute        = false;
            _process.StartInfo.RedirectStandardOutput = true;
            _process.StartInfo.RedirectStandardError  = true;
            _process.OutputDataReceived += new DataReceivedEventHandler(RunLogHandler);
            _process.ErrorDataReceived  += new DataReceivedEventHandler(ErrorLogHandler);
            if (!_process.Start())
            {
                lock (_errorLogLock) { _errorLog.Add("Failed to start model run."); }
                _runManager.HandleRunExited(this);
            }
            _process.BeginOutputReadLine();
            _process.BeginErrorReadLine();
            _processStatusAdditionalInfo = string.Format("{0:T}", _process.StartTime) + " - ";
            _process.WaitForExit();
        }