src/Foundation/ServiceModel/Gimela.ServiceModel.ManagedDiscovery/DiscoveryProxy/AsyncResult/AsyncResult.cs
/// <summary>
/// Ends the specified result.
/// End should be called when the End function for the asynchronous operation is complete.  It
/// ensures the asynchronous operation is complete, and does some common validation.
/// </summary>
/// <typeparam name="TAsyncResult">The type of the async result.</typeparam>
/// <param name="result">The result.</param>
/// <returns></returns>
Ends the specified result.
End should be called when the End function for the asynchronous operation is complete.  It
ensures the asynchronous operation is complete, and does some common validation.
Ends the specified result . End should be called when the End function for the asynchronous operation is complete . It ensures the asynchronous operation is complete and does some common validation .
protected static TAsyncResult End<TAsyncResult>(IAsyncResult result)
        where TAsyncResult : AsyncResult
    {
      if (result == null)
      {
        throw new ArgumentNullException("result");
      }
      TAsyncResult asyncResult = result as TAsyncResult;
      if (asyncResult == null)
      {
        throw new ArgumentException("Invalid async result.", "result");
      }
      if (asyncResult.endCalled)
      {
        throw new InvalidOperationException("Async object already ended.");
      }
      asyncResult.endCalled = true;
      if (!asyncResult.isCompleted)
      {
        asyncResult.AsyncWaitHandle.WaitOne();
      }
      if (asyncResult.manualResetEvent != null)
      {
        asyncResult.manualResetEvent.Close();
      }
      if (asyncResult.completeException != null)
      {
        throw asyncResult.completeException;
      }
      return asyncResult;
    }
protected static TAsyncResult End < TAsyncResult > ( IAsyncResult result ) where TAsyncResult : AsyncResult { if ( result == null ) { throw new ArgumentNullException ( " " ) ; } TAsyncResult asyncResult = result as TAsyncResult ; if ( asyncResult == null ) { throw new ArgumentException ( " " , " " ) ; } if ( asyncResult . endCalled ) { throw new InvalidOperationException ( " " ) ; } asyncResult . endCalled = true ; if ( ! asyncResult . isCompleted ) { asyncResult . AsyncWaitHandle . WaitOne ( ) ; } if ( asyncResult . manualResetEvent != null ) { asyncResult . manualResetEvent . Close ( ) ; } if ( asyncResult . completeException != null ) { throw asyncResult . completeException ; } return asyncResult ; }
Ends the specified result.
Ends the specified result .
None
result
IAsyncResult
None
typeparam
The type of the async result.
The type of the async result .