Meta.TemplateProfiler.Profile C# (CSharp) Method

Profile() public method

public Profile ( string compiler_binary, string compiler_args, string starting_directory, string source_to_profile, string output_profile ) : void
compiler_binary string
compiler_args string
starting_directory string
source_to_profile string
output_profile string
return void
        public void Profile( string compiler_binary
                           , string compiler_args
                           , string starting_directory
                           , string source_to_profile
                           , string output_profile )
        {
            profile_output = new StreamWriter(output_profile);

            profileProcess = new System.Diagnostics.Process();

            try
            {
                string full_args = compiler_binary + " /c /TP " + source_to_profile.Quote() + " " + compiler_args;

                profileProcess.StartInfo.UseShellExecute = false;
                profileProcess.StartInfo.FileName = "cmd.exe";
                profilePane.OutputStringThreadSafe("Command line: cmd.exe " + full_args + Environment.NewLine);
                profileProcess.StartInfo.Arguments = full_args;
                profileProcess.StartInfo.CreateNoWindow = true;
                profileProcess.StartInfo.WorkingDirectory = starting_directory;
                //System.Collections.Specialized.StringDictionary dict = profileProcess.StartInfo.EnvironmentVariables;
                //dict["Path"] += (";" + clTool.VSInstallDir + "Common7\\IDE");
                profileProcess.StartInfo.RedirectStandardError = true;
                profileProcess.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler);
                profileProcess.StartInfo.RedirectStandardOutput = true;
                profileProcess.ErrorDataReceived += new DataReceivedEventHandler(ErrorDataHandler);
                if (cancelProfile)
                    return;
                profileProcess.Start();
                profileProcess.BeginOutputReadLine();
                profileProcess.BeginErrorReadLine();
                profileProcess.WaitForExit();
                // This code assumes the process you are starting will terminate itself.
                // Given that is is started without a window so you cannot terminate it
                // on the desktop, it must terminate itself or you can do it programmatically
                // from this application using the Kill method.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                profile_output.Close();
            }
        }