Exemple #1
0
        /// <devdoc>
        /// <para>
        /// Instructs the <see cref='System.Diagnostics.Process'/> component to start
        /// reading the StandardError stream asynchronously. The user can register a callback
        /// that will be called when a line of data terminated by \n,\r or \r\n is reached, or the end of stream is reached
        /// then the remaining information is returned. The user can add an event handler to ErrorDataReceived.
        /// </para>
        /// </devdoc>
        public void BeginErrorReadLine()
        {
            if (_errorStreamReadMode == StreamReadMode.Undefined)
            {
                _errorStreamReadMode = StreamReadMode.AsyncMode;
            }
            else if (_errorStreamReadMode != StreamReadMode.AsyncMode)
            {
                throw new InvalidOperationException(SR.CantMixSyncAsyncOperation);
            }

            if (_pendingErrorRead)
            {
                throw new InvalidOperationException(SR.PendingAsyncOperation);
            }

            _pendingErrorRead = true;
            // We can't detect if there's a pending synchronous read, stream also doesn't.
            if (_error == null)
            {
                if (_standardError == null)
                {
                    throw new InvalidOperationException(SR.CantGetStandardError);
                }

                Stream s = _standardError.BaseStream;
                _error = new AsyncStreamReader(s, ErrorReadNotifyUser, _standardError.CurrentEncoding);
            }
            _error.BeginReadLine();
        }
 public Process()
 {
     this.machineName = ".";
     this.outputStreamReadMode = StreamReadMode.undefined;
     this.errorStreamReadMode = StreamReadMode.undefined;
     this.m_processAccess = 0x1f0fff;
 }
Exemple #3
0
 private Process(string machineName, bool isRemoteMachine, int processId, ProcessInfo processInfo)
 {
     GC.SuppressFinalize(this);
     _processInfo          = processInfo;
     _machineName          = machineName;
     _isRemoteMachine      = isRemoteMachine;
     _processId            = processId;
     _haveProcessId        = true;
     _outputStreamReadMode = StreamReadMode.Undefined;
     _errorStreamReadMode  = StreamReadMode.Undefined;
 }
Exemple #4
0
        /// <devdoc>
        ///    <para>
        ///       Initializes a new instance of the <see cref='System.Diagnostics.Process'/> class.
        ///    </para>
        /// </devdoc>
        public Process()
        {
            // This class once inherited a finalizer. For backward compatibility it has one so that
            // any derived class that depends on it will see the behaviour expected. Since it is
            // not used by this class itself, suppress it immediately if this is not an instance
            // of a derived class it doesn't suffer the GC burden of finalization.
            if (GetType() == typeof(Process))
            {
                GC.SuppressFinalize(this);
            }

            _machineName          = ".";
            _outputStreamReadMode = StreamReadMode.Undefined;
            _errorStreamReadMode  = StreamReadMode.Undefined;
        }
 private Process(string machineName, bool isRemoteMachine, int processId, ProcessInfo processInfo)
 {
     this.processInfo = processInfo;
     this.machineName = machineName;
     this.isRemoteMachine = isRemoteMachine;
     this.processId = processId;
     this.haveProcessId = true;
     this.outputStreamReadMode = StreamReadMode.undefined;
     this.errorStreamReadMode = StreamReadMode.undefined;
     this.m_processAccess = 0x1f0fff;
 }
 public void BeginOutputReadLine()
 {
     if (this.outputStreamReadMode == StreamReadMode.undefined)
     {
         this.outputStreamReadMode = StreamReadMode.asyncMode;
     }
     else if (this.outputStreamReadMode != StreamReadMode.asyncMode)
     {
         throw new InvalidOperationException(SR.GetString("CantMixSyncAsyncOperation"));
     }
     if (this.pendingOutputRead)
     {
         throw new InvalidOperationException(SR.GetString("PendingAsyncOperation"));
     }
     this.pendingOutputRead = true;
     if (this.output == null)
     {
         if (this.standardOutput == null)
         {
             throw new InvalidOperationException(SR.GetString("CantGetStandardOut"));
         }
         Stream baseStream = this.standardOutput.BaseStream;
         this.output = new AsyncStreamReader(this, baseStream, new UserCallBack(this.OutputReadNotifyUser), this.standardOutput.CurrentEncoding);
     }
     this.output.BeginReadLine();
 }