Beispiel #1
0
 internal void BeginExecuteAsyncCommand(string commandText, bool runInShell, IDebugUnixShellCommandCallback callback, out IDebugUnixShellAsyncCommand asyncCommand)
 {
     if (runInShell)
     {
         var command = new AD7UnixAsyncShellCommand(new StreamingShell(_remoteSystem), callback);
         command.Start(commandText);
         asyncCommand = command;
     }
     else
     {
         var command = new AD7UnixAsyncCommand(_remoteSystem, callback);
         command.Start(commandText);
         asyncCommand = command;
     }
 }
        public int ExecuteCommand(string commandText, int timeout, out string commandOutput)
        {
            if (_currentCommand != null)
            {
                throw new InvalidOperationException("already a command processing");
            }
            _commandCompleteEvent.Reset();

            ShellCommandCallback     commandCallback = new ShellCommandCallback(_commandCompleteEvent);
            AD7UnixAsyncShellCommand command         = new AD7UnixAsyncShellCommand(_commandRunner, commandCallback, false);

            try
            {
                _currentCommand = command;
                _currentCommand.Start(commandText);
                if (!_commandCompleteEvent.WaitOne(timeout))
                {
                    commandOutput = "Command Timeout";
                    return(1460); // ERROR_TIMEOUT
                }

                commandOutput = commandCallback.CommandOutput.Trim('\n', '\r'); // trim ending newlines
                return(commandCallback.ExitCode);
            }
            catch (ObjectDisposedException)
            {
                Debug.Fail("Why are we operating on a disposed object?");
                commandOutput = "ObjectDisposedException";
                return(1999);
            }
            finally
            {
                _currentCommand.Close();
                _currentCommand = null;
            }
        }