public override WebResponse EndGetResponse(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            if (!asyncResult.IsCompleted)
            {
                asyncResult.AsyncWaitHandle.WaitOne();
            }
            AsyncResult         async = (AsyncResult)asyncResult;
            GetResponseCallback cb    = (GetResponseCallback)async.AsyncDelegate;

#if SSHARP
            FileWebResponse webResponse = (FileWebResponse)cb.EndInvokeEx(asyncResult);
#else
            FileWebResponse webResponse = (FileWebResponse)cb.EndInvoke(asyncResult);
#endif
            asyncResponding = false;
            if (webResponse.HasError)
            {
                throw webResponse.Error;
            }
            return(webResponse);
        }
Esempio n. 2
0
        /// <summary>Ends an asynchronous request for a file system resource.</summary>
        /// <returns>A <see cref="T:System.Net.WebResponse" /> that contains the response from the file system resource.</returns>
        /// <param name="asyncResult">An <see cref="T:System.IAsyncResult" /> that references the pending request for a response. </param>
        /// <exception cref="T:System.ArgumentNullException">
        ///   <paramref name="asyncResult" /> is null. </exception>
        public override WebResponse EndGetResponse(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            if (!asyncResult.IsCompleted)
            {
                asyncResult.AsyncWaitHandle.WaitOne();
            }
            AsyncResult         asyncResult2        = (AsyncResult)asyncResult;
            GetResponseCallback getResponseCallback = (GetResponseCallback)asyncResult2.AsyncDelegate;
            WebResponse         result = getResponseCallback.EndInvoke(asyncResult);

            asyncResponding = false;
            return(result);
        }