Exemple #1
0
        private void btbExec_Click(object sender, EventArgs e)
        {
            exeThread = false;
            ThreadWait();
            string input;
            string paramt;

            if (scriptVerified)
            {
                if (txtInput.Text.Contains(" "))
                {
                    input  = txtInput.Text.Split(' ')[0];
                    paramt = txtInput.Text.Split(' ')[1];
                    if (paramt == "-forever")
                    {
                        t = new Thread(() => { ThreadRuntime(input); })
                        {
                            Name = "Runtime Thread"
                        };
                        t.IsBackground = true;
                        exeThread      = true;

                        t.Start();
                    }
                    else
                    {
#if CALLTRACK || ALLTRACK
                        PeformanceTracker.StartStopWatch(txtInput.Text);
#endif
                        ParseTree t = new ParseTree(txtInput.Text);
                        es.ExecuteTree(t);
                        lblTicks.Text = ((Number)es.sys.Get("ticks")).val.ToString();
                        pbSim.Refresh();
#if CALLTRACK || ALLTRACK
                        PeformanceTracker.Stop(txtInput.Text);
#endif
                    }
                }
                else
                {
#if CALLTRACK || ALLTRACK
                    PeformanceTracker.StartStopWatch(txtInput.Text);
#endif
                    ParseTree t = new ParseTree(txtInput.Text);
                    es.ExecuteTree(t);
                    lblTicks.Text = ((Number)es.sys.Get("ticks")).val.ToString();
                    pbSim.Refresh();
#if CALLTRACK || ALLTRACK
                    PeformanceTracker.Stop(txtInput.Text);
#endif
                }
            }
        }
Exemple #2
0
        private void ThreadRuntime(string input)
        {
            string text = txtInput.Text;

            while (exeThread)
            {
#if CALLTRACK || ALLTRACK
                PeformanceTracker.StartStopWatch(text);
#endif

                try
                {
                    ParseTree ts = new ParseTree(input);
                    es.ExecuteTree(ts);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(Environment.NewLine);
                    Console.WriteLine(e.StackTrace);
                }

                if (!InvokeRequired)
                {
                    lblTicks.Text = ((Number)es.sys.Get("ticks")).val.ToString();
                }
                else
                {
                    Invoke(new Action(() => { lblTicks.Text = ((Number)es.sys.Get("ticks")).val.ToString(); }));
                }


                if (!InvokeRequired)
                {
                    pbSim.Refresh();
                }
                else
                {
                    Invoke(new Action(() => { pbSim.Refresh(); }));
                }
#if CALLTRACK || ALLTRACK
                PeformanceTracker.Stop(text);
#endif
            }
        }