protected IAsyncResult AsyncPageBeginProcessRequest(HttpContext context, AsyncCallback callback, object extraData) { this.SetIntrinsics(context, true); if (this._asyncInfo == null) { this._asyncInfo = new PageAsyncInfo(this); } this._asyncInfo.AsyncResult = new HttpAsyncResult(callback, extraData); this._asyncInfo.CallerIsBlocking = callback == null; try { this._context.InvokeCancellableCallback(new WaitCallback(this.AsyncPageProcessRequestBeforeAsyncPointCancellableCallback), null); } catch (Exception exception) { if (this._context.SyncContext.PendingOperationsCount == 0) { throw; } this._asyncInfo.SetError(exception); } if ((this._asyncTaskManager != null) && !this._asyncInfo.CallerIsBlocking) { this._asyncTaskManager.RegisterHandlersForPagePreRenderCompleteAsync(); } this._asyncInfo.AsyncPointReached = true; this._context.SyncContext.Disable(); this._asyncInfo.CallHandlers(true); return this._asyncInfo.AsyncResult; }
public void AddOnPreRenderCompleteAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state) { if (beginHandler == null) { throw new ArgumentNullException("beginHandler"); } if (endHandler == null) { throw new ArgumentNullException("endHandler"); } if (this._asyncInfo == null) { if (!(this is IHttpAsyncHandler)) { throw new InvalidOperationException(System.Web.SR.GetString("Async_required")); } this._asyncInfo = new PageAsyncInfo(this); } if (this._asyncInfo.AsyncPointReached) { throw new InvalidOperationException(System.Web.SR.GetString("Async_addhandler_too_late")); } this._asyncInfo.AddHandler(beginHandler, endHandler, state); }