コード例 #1
0
ファイル: MainForm.cs プロジェクト: sawickiap/FxBatchCompiler
        // Help > Fxc Parameters
        private void FxcParametersMenuItem_Click(object sender, EventArgs e)
        {
            string FxcPath;
            if (EnsureFxcPath(out FxcPath))
            {
                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    ConsoleCommand cmd = new ConsoleCommand();
                    int timeout = 3000;
                    cmd.Execute(FxcPath, "/?", null, timeout, null);

                    Cursor.Current = Cursors.Default;

                    ShowTextForm.Go(this, "Fxc Parameters", cmd.StandardOutputData, m_Font);
                }
                catch (Exception ex)
                {
                    Cursor.Current = Cursors.Default;
                    Globals.ShowError(this, ex);
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: sawickiap/FxBatchCompiler
        // Thread procedure of working thread for compilation.
        // There is working threads pool and each one takes net tasks on loop and executes them.
        private void CompilationThreadProc(Object Obj)
        {
            //System.Diagnostics.Debug.WriteLine("Thread started.");

            CompilationData Data = (CompilationData)Obj;

            string FxcPath, DocumentDirectory;
            Data.GetMainData(out FxcPath, out DocumentDirectory);

            //Random rand = new Random();
            while (!Data.IsAborting())
            {
                string Parameters;
                int TaskIndex = Data.StartNextTask(out Parameters);
                //System.Diagnostics.Debug.WriteLine(string.Format("Thread obtained task index {0}", TaskIndex));
                if (TaskIndex == -1) break;

                // Go!
                string Output;
                //Thread.Sleep(rand.Next(100));
                ConsoleCommand cmd = new ConsoleCommand();
                bool succeeded;
                try
                {
                    int timeout = 60000;
                    cmd.Execute(FxcPath, Parameters, DocumentDirectory, timeout, null);
                    succeeded = cmd.ExitCode == 0;
                    Output = cmd.StandardErrorData + cmd.StandardOutputData;
                }
                catch (Exception ex)
                {
                    Output = ex.Message + "\r\n\r\n" + cmd.StandardErrorData + cmd.StandardOutputData;
                    succeeded = false;
                }

                // Analyze output
                Regex ErrorsReg = new Regex(@"\(.+\)\:\serror\s");
                Regex WarningsReg = new Regex(@"\(.+\)\:\swarning\s");

                MatchCollection ErrorsMatches = ErrorsReg.Matches(Output);
                MatchCollection WarningsMatches = WarningsReg.Matches(Output);

                Data.TaskFinished(TaskIndex, Output, succeeded, ErrorsMatches.Count, WarningsMatches.Count);

                //System.Diagnostics.Debug.WriteLine(string.Format("Thread finished task index {0}", TaskIndex));
            }

            Data.OnThreadExit();
            //System.Diagnostics.Debug.WriteLine("Thread finished.");
        }