public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state) { if (string.Compare("GET", method, true) == 0 || string.Compare("HEAD", method, true) == 0 || string.Compare("CONNECT", method, true) == 0) { throw new ProtocolViolationException("Cannot send a content-body with this verb-type."); } lock (this) { if (asyncResponding || webResponse != null) { throw new InvalidOperationException("This operation cannot be performed after the request has been submitted."); } if (requesting) { throw new InvalidOperationException("Cannot re-call start of asynchronous method while a previous call is still in progress."); } requesting = true; } GetRequestStreamCallback c = new GetRequestStreamCallback(this.GetRequestStreamInternal); #if SSHARP return(c.BeginInvokeEx(callback, state)); #else return(c.BeginInvoke(callback, state)); #endif }
/// <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); }
public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state) { if (string.Compare ("GET", method, true) == 0 || string.Compare ("HEAD", method, true) == 0 || string.Compare ("CONNECT", method, true) == 0) throw new ProtocolViolationException ("Cannot send a content-body with this verb-type."); lock (this) { if (asyncResponding || webResponse != null) throw new InvalidOperationException ("This operation cannot be performed after the request has been submitted."); if (requesting) throw new InvalidOperationException ("Cannot re-call start of asynchronous method while a previous call is still in progress."); requesting = true; } GetRequestStreamCallback c = new GetRequestStreamCallback (this.GetRequestStreamInternal); return c.BeginInvoke (callback, state); }