Ejemplo n.º 1
0
		protected override void VerifyAndProcessRequest(IHttpHandler handler, HttpContextBase context)
		{
			Precondition.Require(handler, () => Error.ArgumentNull("handler"));
			Precondition.Require(context, () => Error.ArgumentNull("context"));

			handler.ProcessRequest(context.Unwrap());
		}
		protected virtual IAsyncResult BeginProcessRequest(
			HttpContextBase context, AsyncCallback callback, object state)
		{
			IHttpHandler handler = GetHttpHandler(context);
			IHttpAsyncHandler asyncHandler = (handler as IHttpAsyncHandler);

			if (asyncHandler == null)
			{
				Action action = delegate {
					handler.ProcessRequest(context.Unwrap());
				};
				return AsyncResultWrapper.BeginSynchronous(callback, state, action, _tag);
			}
			BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState) {
				return asyncHandler.BeginProcessRequest(context.Unwrap(), asyncCallback, asyncState);
			};
			EndInvokeDelegate endDelegate = delegate(IAsyncResult asyncResult) {
				asyncHandler.EndProcessRequest(asyncResult);
			};
			return AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _tag);
		}