diff --git a/src/Renci.SshNet/Common/AsyncResult.cs b/src/Renci.SshNet/Common/AsyncResult.cs index b4ac4036..7b27ccb8 100644 --- a/src/Renci.SshNet/Common/AsyncResult.cs +++ b/src/Renci.SshNet/Common/AsyncResult.cs @@ -11,16 +11,16 @@ namespace Renci.SshNet.Common // Fields set at construction which never change while operation is pending private readonly AsyncCallback _asyncCallback; - private readonly Object _asyncState; + private readonly object _asyncState; // Field set at construction which do change after operation completes - private const Int32 StatePending = 0; + private const int StatePending = 0; - private const Int32 StateCompletedSynchronously = 1; + private const int StateCompletedSynchronously = 1; - private const Int32 StateCompletedAsynchronously = 2; + private const int StateCompletedAsynchronously = 2; - private Int32 _completedState = StatePending; + private int _completedState = StatePending; // Field that may or may not get set depending on usage private ManualResetEvent _asyncWaitHandle; @@ -32,7 +32,7 @@ namespace Renci.SshNet.Common /// Gets or sets a value indicating whether EndInvoke has been called on the current AsyncResult. /// /// - /// true if EndInvoke has been called on the current AsyncResult; otherwise, false. + /// true if has been called on the current ; otherwise, false. /// public bool EndInvokeCalled { get; private set; } @@ -41,7 +41,7 @@ namespace Renci.SshNet.Common /// /// The async callback. /// The state. - protected AsyncResult(AsyncCallback asyncCallback, Object state) + protected AsyncResult(AsyncCallback asyncCallback, object state) { _asyncCallback = asyncCallback; _asyncState = state; @@ -52,7 +52,7 @@ namespace Renci.SshNet.Common /// /// The exception. /// if set to true [completed synchronously]. - public void SetAsCompleted(Exception exception, Boolean completedSynchronously) + public void SetAsCompleted(Exception exception, bool completedSynchronously) { // Passing null for exception means no error occurred; this is the common case _exception = exception; @@ -99,21 +99,21 @@ namespace Renci.SshNet.Common /// 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 { return _asyncState; } } + public object AsyncState { get { return _asyncState; } } /// /// Gets a value that indicates whether the asynchronous operation completed synchronously. /// /// true if the asynchronous operation completed synchronously; otherwise, false. - public Boolean CompletedSynchronously + public bool CompletedSynchronously { get { return _completedState == StateCompletedSynchronously; } } /// - /// Gets a that is used to wait for an asynchronous operation to complete. + /// 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. + /// A that is used to wait for an asynchronous operation to complete. public WaitHandle AsyncWaitHandle { get @@ -144,8 +144,9 @@ namespace Renci.SshNet.Common /// /// Gets a value that indicates whether the asynchronous operation has completed. /// - /// true if the operation is complete; otherwise, false. - public Boolean IsCompleted + /// + /// true if the operation is complete; otherwise, false. + public bool IsCompleted { get { return _completedState != StatePending; } } @@ -162,11 +163,11 @@ namespace Renci.SshNet.Common private TResult _result; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The async callback. /// The state. - protected AsyncResult(AsyncCallback asyncCallback, Object state) + protected AsyncResult(AsyncCallback asyncCallback, object state) : base(asyncCallback, state) { } @@ -176,19 +177,21 @@ namespace Renci.SshNet.Common /// /// The result. /// if set to true [completed synchronously]. - public void SetAsCompleted(TResult result, Boolean completedSynchronously) + public void SetAsCompleted(TResult result, bool completedSynchronously) { // Save the asynchronous operation's result _result = result; // Tell the base class that the operation completed successfully (no exception) - base.SetAsCompleted(null, completedSynchronously); + SetAsCompleted(null, completedSynchronously); } /// /// Waits until the asynchronous operation completes, and then returns the value generated by the asynchronous operation. /// - /// Invocation result + /// + /// The invocation result. + /// public new TResult EndInvoke() { base.EndInvoke(); // Wait until operation has completed