private bool PostSendCommandProcessing(ref Stream stream)
{
if (_doRead)
{
// In async case, the next call 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 the
// next call returns
bool isAsync = _isAsync;
int index = _index;
PipelineEntry[] commands = _commands;
try
{
ResponseDescription response = ReceiveCommandResponse();
if (isAsync)
{
return true;
}
_currentResponseDescription = response;
}
catch
{
// If we get an exception on the QUIT command (which is
// always the last command), ignore the final exception
// and continue with the pipeline regardlss of sync/async
if (index < 0 || index >= commands.Length ||
commands[index].Command != "QUIT\r\n")
throw;
}
}
return PostReadCommandProcessing(ref stream);
}