using System;
using System.Threading;
namespace Renci.SshClient
{
    /// 
    /// Provides additional information for asynchronous command execution
    /// 
    public class CommandAsyncResult : IAsyncResult
    {
        /// 
        /// Gets or sets the command that async result was created for.
        /// 
        /// The channel.
        private SshCommand _command;
        /// 
        /// Gets or sets the bytes received. If SFTP only file bytes are counted.
        /// 
        /// Total bytes received.
        public int BytesReceived { get; set; }
        /// 
        /// Gets or sets the bytes sent by SFTP.
        /// 
        /// Total bytes sent.
        public int BytesSent { get; set; }
        #region IAsyncResult Members
        /// 
        /// Gets a user-defined object that qualifies or contains information about an asynchronous operation.
        /// 
        /// A user-defined object that qualifies or contains information about an asynchronous operation.
        public object AsyncState { get; internal set; }
        /// 
        /// Gets a  that is used to wait for an asynchronous operation to complete.
        /// 
        /// A  that is used to wait for an asynchronous operation to complete.
        public WaitHandle AsyncWaitHandle { get; internal set; }
        /// 
        /// Gets a value that indicates whether the asynchronous operation completed synchronously.
        /// 
        /// true if the asynchronous operation completed synchronously; otherwise, false.
        public bool CompletedSynchronously { get; internal set; }
        /// 
        /// Gets a value that indicates whether the asynchronous operation has completed.
        /// 
        /// true if the operation is complete; otherwise, false.
        public bool IsCompleted { get; internal set; }
        #endregion
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// The command.
        internal CommandAsyncResult(SshCommand command)
        {
            this._command = command;
        }
        /// 
        /// Validates that command object is valid to be used with this instance.
        /// 
        /// The command.
        public void ValidateCommand(SshCommand command)
        {
            if (this._command != command)
            {
                throw new InvalidOperationException("Invalid IAsyncResult parameter");
            }
        }
    }
}