예제 #1
0
        /// <summary>Ends an asynchronous request for a <see cref="T:System.IO.Stream" /> instance that the application uses to write data.</summary>
        /// <returns>A <see cref="T:System.IO.Stream" /> object that the application uses to write data.</returns>
        /// <param name="asyncResult">An <see cref="T:System.IAsyncResult" /> that references the pending request for a stream. </param>
        /// <exception cref="T:System.ArgumentNullException">
        ///   <paramref name="asyncResult" /> is null. </exception>
        public override Stream EndGetRequestStream(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            if (!asyncResult.IsCompleted)
            {
                asyncResult.AsyncWaitHandle.WaitOne();
            }
            AsyncResult asyncResult2 = (AsyncResult)asyncResult;
            GetRequestStreamCallback getRequestStreamCallback = (GetRequestStreamCallback)asyncResult2.AsyncDelegate;

            return(getRequestStreamCallback.EndInvoke(asyncResult));
        }
        public override Stream EndGetRequestStream(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            if (!asyncResult.IsCompleted)
            {
                asyncResult.AsyncWaitHandle.WaitOne();
            }
            AsyncResult async           = (AsyncResult)asyncResult;
            GetRequestStreamCallback cb = (GetRequestStreamCallback)async.AsyncDelegate;

#if SSHARP
            var result = cb.EndInvokeEx <Stream> (asyncResult);
#else
            var result = cb.EndInvoke(asyncResult);
#endif
            requesting = false;

            return(result);
        }