public AsyncContext(Delegate @delegate, DelegateAsyncResult delegateAsyncResult, AsyncCallback asyncCallback, object userState) { AsyncDelegate = @delegate; AsyncCallback = asyncCallback; AsyncState = userState; DelegateAsyncResult = delegateAsyncResult; }
public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state) { GetResponseDelegate d = new GetResponseDelegate(GetAsyncResponse); DelegateAsyncResult result = new DelegateAsyncResult(); AsyncContext userContext = new AsyncContext(d, result, callback, state); result.AsyncResult = d.BeginInvoke(new AsyncCallback(DelegateAsyncResult.Callback), userContext); return(result); }
public override WebResponse EndGetResponse(IAsyncResult asyncResult) { if (_isAborted) { throw new WebException("The operation has been aborted.", WebExceptionStatus.RequestCanceled); } if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } DelegateAsyncResult result = asyncResult as DelegateAsyncResult; if (result == null) { throw new ArgumentException("Invalid IAsyncResult", "asyncResult"); } return(((GetResponseDelegate)result.AsyncDelegate).EndInvoke(result.AsyncResult)); }