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