/// <summary>
 /// Initializes a new instance of the <see cref="ReadBufferIoResult"/> class.
 /// Constructor, given a plain IoResult, plus type and origin.
 /// </summary>
 /// <param name="r">Plain IoResult.</param>
 /// <param name="type">ASCII or EBCDIC mode.</param>
 /// <param name="origin">Coordinate origin.</param>
 public ReadBufferIoResult(IoResult r, ReadBufferType type, int origin)
     : base(r)
 {
     // Initialize the ReadBufferType.
     this.ReadBufferType = type;
     this.Origin         = origin;
 }
 /// <summary>
 /// Read the 3270 display buffer.
 /// </summary>
 /// <param name="type">ASCII or EBCDIC mode.</param>
 /// <returns>Success/failure and result.</returns>
 /// <exception cref="InvalidOperationException">Session is not started.</exception>
 /// <exception cref="X3270ifCommandException"><see cref="ExceptionMode"/> is enabled and the command fails.</exception>
 public ReadBufferIoResult ReadBuffer(ReadBufferType type = ReadBufferType.Ascii)
 {
     try
     {
         return(this.ReadBufferAsync(type).Result);
     }
     catch (AggregateException e)
     {
         throw e.InnerException;
     }
 }
        /// <summary>
        /// Async version of ReadBuffer.
        /// </summary>
        /// <param name="type">Type of operation (ASCII or EBCDIC).</param>
        /// <returns>I/O result.</returns>
        /// <exception cref="InvalidOperationException">Session is not started.</exception>
        /// <exception cref="X3270ifCommandException"><see cref="ExceptionMode"/> is enabled and the command fails.</exception>
        public async Task <ReadBufferIoResult> ReadBufferAsync(ReadBufferType type = ReadBufferType.Ascii)
        {
            var result = await this.IoAsync("ReadBuffer(" + type.ToString() + ")").ConfigureAwait(continueOnCapturedContext: false);

            return(new ReadBufferIoResult(result, type, this.Config.Origin));
        }