System.Net.HttpWebRequest.EndGetRequestStream C# (CSharp) Метод

EndGetRequestStream() публичный Метод

public EndGetRequestStream ( IAsyncResult asyncResult ) : Stream
asyncResult IAsyncResult
Результат Stream
        public override Stream EndGetRequestStream(IAsyncResult asyncResult)
        {
            CheckAbort();

            if (asyncResult == null || !(asyncResult is Task<Stream>))
            {
                throw new ArgumentException(SR.net_io_invalidasyncresult, nameof(asyncResult));
            }

            if (Interlocked.Exchange(ref _endGetRequestStreamCalled, 1) != 0)
            {
                throw new InvalidOperationException(SR.Format(SR.net_io_invalidendcall, "EndGetRequestStream"));
            }

            Stream stream;
            try
            {
                stream = ((Task<Stream>)asyncResult).GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                throw WebException.CreateCompatibleException(ex);
            }

            return stream;
        }

Same methods

HttpWebRequest::EndGetRequestStream ( IAsyncResult asyncResult, TransportContext &context ) : Stream
HttpWebRequest::EndGetRequestStream ( System asyncResult ) : System.IO.Stream
HttpWebRequest::EndGetRequestStream ( System asyncResult, System &context ) : System.IO.Stream

Usage Example

 private Stream GetRequestStreamAsynch(HttpWebRequest request)
 {
     return AsynchHelper.WaitForAsynchResponse(
         c => request.BeginGetRequestStream(c, null),
         (r, s) => request.EndGetRequestStream(r)
     );
 }
All Usage Examples Of System.Net.HttpWebRequest::EndGetRequestStream