Example #1
0
        /// <summary>
        /// Launch a process of bspzip.exe with the given arguments
        /// </summary>
        protected void StartProcess()
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(game.BspZip, GetProcessArguments())
            {
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true,
            };

            startInfo.EnvironmentVariables["VPROJECT"] = game.GameInfoFolder;

            Process p = new Process {
                StartInfo = startInfo
            };

            if (isSyncLogsOutput)
            {
                // Sync output
                p.Start();
                string output = p.StandardOutput.ReadToEnd();
                logsOutput.AppendLine(output);
                p.WaitForExit();
            }
            else
            {
                // Async output
                p.OutputDataReceived += new DataReceivedEventHandler(ProcessOutputHandler);
                p.ErrorDataReceived  += new DataReceivedEventHandler(ProcessErrorHandler);
                p.Start();
                p.BeginOutputReadLine();
                p.WaitForExit();
                p.Close();
            }

            // To stop the output reading
            // p.CancelOutputRead();
            // p.Close()
        }