Beispiel #1
0
        private void CreateInterpreterThread()
        {
            _interpreterThread = new Thread(() =>
            {
                while (true)
                {
                    _interpreterReset.WaitOne();

                    if (IsMultiLine)
                    {
                        ExecuteStatements(Code);
                    }
                    else
                    {
                        var c = Code;
                        CodeViewer.BeginInvoke(() => Code = "");
                        ExecuteExpression(c);
                    }

                    CodeViewer.BeginInvoke(() =>
                    {
                        Status      = "Done";
                        IsExecuting = false;
                        _callback?.Invoke();
                    });
                }
            })
            {
                IsBackground = true
            };

            _interpreterThread.Start();
        }
Beispiel #2
0
        private void UpdateVariables()
        {
            var variables = Interpreter.CurrentScope
                            .Select(x => new VariableViewModel()
            {
                Name  = x.Key,
                Value = x.Value?.Value,
            })
                            .ToArray();

            CodeViewer.BeginInvoke(() =>
            {
                Variables.Clear();
                variables.For(Variables.Add);
            });
        }
Beispiel #3
0
        public void Stop()
        {
            IsExecuting = false;

            Task.Run(() =>
            {
                if (_interpreterThread != null)
                {
                    try
                    {
                        _interpreterThread.Abort();
                    }
                    catch { }

                    _interpreterThread = null;
                }

                CodeViewer.AppendOutput("Stopped");
                CodeViewer.BeginInvoke(() => Status = "Script stopped");
            });
        }