System.Net.CommandStream.ContinueCommandPipeline C# (CSharp) Method

ContinueCommandPipeline() protected method

protected ContinueCommandPipeline ( ) : Stream
return Stream
        protected Stream ContinueCommandPipeline()
        {
            // In async case, The BeginWrite can actually result in a
            // series of synchronous completions that eventually close
            // the connection. So we need to save the members that 
            // we need to access, since they may not be valid after 
            // BeginWrite returns
            bool isAsync = _isAsync;
            while (_index < _commands.Length)
            {
                if (_doSend)
                {
                    if (_index < 0)
                        throw new InternalException();

                    byte[] sendBuffer = Encoding.GetBytes(_commands[_index].Command);

                    if (NetEventSource.Log.IsEnabled())
                    {
                        string sendCommand = _commands[_index].Command.Substring(0, _commands[_index].Command.Length - 2);
                        if (_commands[_index].HasFlag(PipelineEntryFlags.DontLogParameter))
                        {
                            int index = sendCommand.IndexOf(' ');
                            if (index != -1)
                                sendCommand = sendCommand.Substring(0, index) + " ********";
                        }
                        if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Sending command {sendCommand}");
                    }

                    try
                    {
                        if (isAsync)
                        {
                            BeginWrite(sendBuffer, 0, sendBuffer.Length, s_writeCallbackDelegate, this);
                        }
                        else
                        {
                            Write(sendBuffer, 0, sendBuffer.Length);
                        }
                    }
                    catch (IOException)
                    {
                        MarkAsRecoverableFailure();
                        throw;
                    }
                    catch
                    {
                        throw;
                    }

                    if (isAsync)
                    {
                        return null;
                    }
                }

                Stream stream = null;
                bool isReturn = PostSendCommandProcessing(ref stream);
                if (isReturn)
                {
                    return stream;
                }
            }

            lock (this)
            {
                Close();
            }

            return null;
        }

Usage Example

Beispiel #1
0
        /// <summary>
        ///    <para>Provides a wrapper for the async write operations</para>
        /// </summary>
        private static void WriteCallback(IAsyncResult asyncResult)
        {
            CommandStream connection = (CommandStream)asyncResult.AsyncState;

            try {
                try {
                    connection.EndWrite(asyncResult);
                }
                catch (IOException) {
                    connection.MarkAsRecoverableFailure();
                    throw;
                }
                catch {
                    throw;
                }
                Stream stream = null;
                if (connection.PostSendCommandProcessing(ref stream))
                {
                    return;
                }
                connection.ContinueCommandPipeline();
            } catch (Exception e) {
                connection.Abort(e);
            }
        }
All Usage Examples Of System.Net.CommandStream::ContinueCommandPipeline