예제 #1
0
        public async Task <Tuple <InterpreterCondition, string> > Execute(string code)
        {
            lock (_lockObject)
            {
                if (Condition != InterpreterCondition.Stopped)
                {
                    _interpreter.Stop();
                    _executingCode.Wait();
                }
                Condition         = InterpreterCondition.Running;
                _tcs              = new TaskCompletionSource <InterpreterCondition>();
                _interpreter.Code = code;

                _executingCode = new Task(
                    () => {
                    _interpreter.Run();
                    _tcs.SetResult(InterpreterCondition.Finished);
                    Condition = InterpreterCondition.Stopped;
                }
                    );

                _executingCode.Start();
            }
            return(new Tuple <InterpreterCondition, string>(await _tcs.Task, Output));
        }
예제 #2
0
 private void InputAction()
 {
     lock (_lockObject)
     {
         _tcs.SetResult(InterpreterCondition.WaitingForInput);
         Condition = InterpreterCondition.WaitingForInput;
         _tcs      = new TaskCompletionSource <InterpreterCondition>();
     }
 }