ASP.Net: IHttpAsyncHandler and AsyncProcessorDelegate
Posted
by ctrlShiftBryan
on Stack Overflow
See other posts from Stack Overflow
or by ctrlShiftBryan
Published on 2010-03-26T19:33:03Z
Indexed on
2010/03/26
19:43 UTC
Read the original article
Hit count: 1262
I have implemented an IHttpAsyncHandler. I am making about 5 different AJAX calls from a webpage that has widgets to that handler.
One of those widgets takes about 15 seconds to load(because of a large database query) the others should all load in under a second. The handler is responding in a synchronous manner.
I am getting very inconsistent results. The ProcessRequest method is using Session and other class level variables. Could that be causing different requests to use the same thread instead each there own?
I'm getting this...
Request1 ---> response 1 sec
Request2 ---> response 14 sec
Request3 ---> response 14.5 sec
Request4 ---> response 15 sec
Request5 ---> response 15.5 sec
but I'm looking for something more like this...
Request1 ---> response 1 sec
Request2 ---> response 14 sec
Request3 ---> response 1.5 sec
Request4 ---> response 2 sec
Request5 ---> response 1.5 sec
Without posting too much code my implementation of the IHttpAsyncHandler methods are pretty standard.
private AsyncProcessorDelegate _Delegate;
protected delegate void AsyncProcessorDelegate(HttpContext context);
IAsyncResult IHttpAsyncHandler.BeginProcessRequest(HttpContext context,
AsyncCallback cb, object extraData)
{
_Delegate = new AsyncProcessorDelegate(ProcessRequest);
return _Delegate.BeginInvoke(context, cb, extraData);
}
void IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
{
_Delegate.EndInvoke(result);
}
Putting a debug break point in my IHttpAsyncHandler.BeginProcessRequest method I can see that the method isn't being fired until the last Process is complete.
Also my machine.config has this entry... processModel autoConfig="true" with no other properties set.
What else do I need to check for?
© Stack Overflow or respective owner