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); }
public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state) { lock (this) { if (asyncResponding) { throw new InvalidOperationException("Cannot re-call start of asynchronous method while a previous call is still in progress."); } asyncResponding = true; } GetResponseCallback c = new GetResponseCallback(this.GetResponseInternal); return(c.BeginInvoke(callback, state)); }
/// <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); }
public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state) { lock (this) { if (asyncResponding) throw new InvalidOperationException ("Cannot re-call start of asynchronous method while a previous call is still in progress."); asyncResponding = true; } GetResponseCallback c = new GetResponseCallback (this.GetResponseInternal); return c.BeginInvoke (callback, state); }