示例#1
0
        void AsyncReaderWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            //EventArgs ea = new EventArgs();
            //texProcess_Exited(texProcess, ea);
            AsyncReaderReturnType ret = e.Result as AsyncReaderReturnType;

            texprocess_Exited(ret.stdout, ret.stderr);
        }
示例#2
0
        void AsyncReaderWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            // read asynchronously from the process output
            StringWriter sw = new StringWriter();
            StringWriter ew = new StringWriter();

            try
            {
                // read all output from stdout
                string line;
                while ((line = texProcess.StandardOutput.ReadLine()) != null)
                {
                    sw.WriteLine(line);
                    // call handler
                    texProcess_OutputDataReceived(texProcess, line);
                }

                // read all output from stderr
                //err_out = texProcess.StandardError.ReadToEnd();
                while ((line = texProcess.StandardError.ReadLine()) != null)
                {
                    ew.WriteLine(line);
                    // call handler
                    texProcess_OutputDataReceived(texProcess, line);
                }
            }
            catch (ThreadAbortException)
            {
                // process terminated by user
                MainWindow.AddStatusLine("PdfLatex: process terminated by user.", true);
            }
            finally
            {
                texProcess.WaitForExit();
                AsyncReaderReturnType ret = new AsyncReaderReturnType();
                ret.stderr = ew.ToString();
                ret.stdout = sw.ToString();
                e.Result   = ret;
            }
        }
示例#3
0
        void AsyncReaderWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
        //    GlobalUI.AddStatusLine(this, "asyncreader called");
            Job job = e.Argument as Job;

            // read asynchronously from the process output
            StringWriter sw = new StringWriter();
            StringWriter ew = new StringWriter();
            try
            {
                // read all output from stdout
                string line;
                while ((line = texProcess.StandardOutput.ReadLine()) != null)
                {
      //              GlobalUI.AddStatusLine(this, "asyncreader 0");
                    sw.WriteLine(line);
                    // call handler
                    //texProcess_OutputDataReceived(texProcess, line);
                    string line2 = line; // we need a new variable in the closure below
                    MyBackgroundWorker.BeginInvoke(() => { if (OnTexOutput != null) OnTexOutput(this, new CompileEventArgs(line2)); });
                }
        //        GlobalUI.AddStatusLine(this, "asyncreader 1");
                // read all output from stderr
                //err_out = texProcess.StandardError.ReadToEnd();
                while ((line = texProcess.StandardError.ReadLine()) != null)
                {
                    ew.WriteLine(line);
                    // call handler
                    MyBackgroundWorker.BeginInvoke(() => { if (OnTexOutput != null) OnTexOutput(this, new CompileEventArgs(line)); });
                }
            }
            catch (ThreadAbortException)
            {
                // process terminated by user
                GlobalUI.UI.AddStatusLine(this, "PdfLatex: process terminated by user.", true);
            }
            finally
            {
                texProcess.WaitForExit();
                AsyncReaderReturnType ret = new AsyncReaderReturnType();
                ret.stderr = ew.ToString();
                ret.stdout = sw.ToString();
                // Parse tex errors/warnings and display,... do this here b/c it takes some time and we don't want to bother the UI thread
                ret.OutputParseResult = TexOutputParser.parseOutput(ret.stdout, job);
                e.Result = ret;

                if (texProcess.ExitCode == 0)
                {
                    if (job.BBWritten && !job.GeneratePrecompiledHeaders)
                    {
                        ReadBBFromFile(job);
                    }
                }
            }
        }
示例#4
0
        void AsyncReaderWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            // read asynchronously from the process output
            StringWriter sw = new StringWriter();
            StringWriter ew = new StringWriter();
            try
            {
                // read all output from stdout
                string line;
                while ((line = texProcess.StandardOutput.ReadLine()) != null)
                {
                    sw.WriteLine(line);
                    // call handler
                    texProcess_OutputDataReceived(texProcess, line);
                }

                // read all output from stderr
                //err_out = texProcess.StandardError.ReadToEnd();
                while ((line = texProcess.StandardError.ReadLine()) != null)
                {
                    ew.WriteLine(line);
                    // call handler
                    texProcess_OutputDataReceived(texProcess, line);
                }
            }
            catch (ThreadAbortException)
            {
                // process terminated by user
                MainWindow.AddStatusLine("PdfLatex: process terminated by user.", true);
            }
            finally
            {
                texProcess.WaitForExit();
                AsyncReaderReturnType ret = new AsyncReaderReturnType();
                ret.stderr = ew.ToString();
                ret.stdout = sw.ToString();
                e.Result = ret;
            }
        }