private void ExecuteCommand(string text) { lock (ExecuteCommandLock) { if (TodoThread != null) { TodoThread.Abort(); TodoThread = null; } AIMLPadEditor edit = this; submitButton.Enabled = false; TodoThread = new Thread(() => { robot.AcceptInput(WriteLine, text, user, true, RequestKind.CommandAndChatProcessor, true); if (InvokeRequired) { Invoke(new ThreadStart(() => { edit.PopulateRobotChange(); edit.PopulateUserChange(); submitButton.Enabled = true; consoleInputText.SelectAll(); })); } }); TodoThread.Start(); } }