< Summary

Information
Class: Renci.SshNet.Common.AsyncResult<T>
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Common\AsyncResult{TResult}.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 50
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
SetAsCompleted(...)100%1100%
EndInvoke()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Common\AsyncResult{TResult}.cs

#LineLine coverage
 1using System;
 2
 3namespace Renci.SshNet.Common
 4{
 5    /// <summary>
 6    /// Base class to encapsulates the results of an asynchronous operation that returns result.
 7    /// </summary>
 8    /// <typeparam name="TResult">The type of the result.</typeparam>
 9    public abstract class AsyncResult<TResult> : AsyncResult
 10    {
 11        // Field set when operation completes
 12        private TResult _result;
 13
 14        /// <summary>
 15        /// Initializes a new instance of the <see cref="AsyncResult{TResult}"/> class.
 16        /// </summary>
 17        /// <param name="asyncCallback">The async callback.</param>
 18        /// <param name="state">The state.</param>
 19        protected AsyncResult(AsyncCallback asyncCallback, object state)
 429920            : base(asyncCallback, state)
 429921        {
 429922        }
 23
 24        /// <summary>
 25        /// Marks asynchronous operation as completed.
 26        /// </summary>
 27        /// <param name="result">The result.</param>
 28        /// <param name="completedSynchronously">if set to <see langword="true"/> [completed synchronously].</param>
 29        public void SetAsCompleted(TResult result, bool completedSynchronously)
 419130        {
 31            // Save the asynchronous operation's result
 419132            _result = result;
 33
 34            // Tell the base class that the operation completed successfully (no exception)
 419135            SetAsCompleted(exception: null, completedSynchronously);
 419136        }
 37
 38        /// <summary>
 39        /// Waits until the asynchronous operation completes, and then returns the value generated by the asynchronous o
 40        /// </summary>
 41        /// <returns>
 42        /// The invocation result.
 43        /// </returns>
 44        public new TResult EndInvoke()
 422245        {
 422246            base.EndInvoke(); // Wait until operation has completed
 419047            return _result;  // Return the result (if above didn't throw)
 419048        }
 49    }
 50}