CancelOperation() private method

private CancelOperation ( ) : void
return void
Ejemplo n.º 1
0
        /// <devdoc>
        /// <para>
        /// Instructs the <see cref='System.Diagnostics.Process'/> component to cancel the asynchronous operation
        /// specified by BeginErrorReadLine().
        /// </para>
        /// </devdoc>
        public void CancelErrorRead()
        {
            if (_error != null)
            {
                _error.CancelOperation();
            }
            else
            {
                throw new InvalidOperationException(SR.NoAsyncOperation);
            }

            _pendingErrorRead = false;
        }
Ejemplo n.º 2
0
        /// <devdoc>
        /// <para>
        /// Instructs the <see cref='System.Diagnostics.Process'/> component to cancel the asynchronous operation
        /// specified by BeginOutputReadLine().
        /// </para>
        /// </devdoc>
        public void CancelOutputRead()
        {
            if (_output != null)
            {
                _output.CancelOperation();
            }
            else
            {
                throw new InvalidOperationException(SR.NoAsyncOperation);
            }

            _pendingOutputRead = false;
        }
Ejemplo n.º 3
0
        /// <devdoc>
        ///    <para>
        ///       Frees any resources associated with this component.
        ///    </para>
        /// </devdoc>
        public void Close()
        {
            if (Associated)
            {
                if (_haveProcessHandle)
                {
                    // We need to lock to ensure we don't run concurrently with CompletionCallback.
                    // Without this lock we could reset _raisedOnExited which causes CompletionCallback to
                    // raise the Exited event a second time for the same process.
                    lock (this)
                    {
                        // This sets _waitHandle to null which causes CompletionCallback to not emit events.
                        StopWatchingForExit();
                    }
                    _processHandle.Dispose();
                    _processHandle     = null;
                    _haveProcessHandle = false;
                }
                _haveProcessId   = false;
                _isRemoteMachine = false;
                _machineName     = ".";
                _raisedOnExited  = false;

                // Only call close on the streams if the user cannot have a reference on them.
                // If they are referenced it is the user's responsibility to dispose of them.
                try
                {
                    if (_standardOutput != null && (_outputStreamReadMode == StreamReadMode.AsyncMode || _outputStreamReadMode == StreamReadMode.Undefined))
                    {
                        if (_outputStreamReadMode == StreamReadMode.AsyncMode)
                        {
                            _output.CancelOperation();
                        }
                        _standardOutput.Close();
                    }

                    if (_standardError != null && (_errorStreamReadMode == StreamReadMode.AsyncMode || _errorStreamReadMode == StreamReadMode.Undefined))
                    {
                        if (_errorStreamReadMode == StreamReadMode.AsyncMode)
                        {
                            _error.CancelOperation();
                        }
                        _standardError.Close();
                    }

                    if (_standardInput != null && !_standardInputAccessed)
                    {
                        _standardInput.Close();
                    }
                }
                finally
                {
                    _standardOutput = null;
                    _standardInput  = null;
                    _standardError  = null;

                    _output = null;
                    _error  = null;

                    CloseCore();
                    Refresh();
                }
            }
        }