Synchronous database is read inside IHttpAsyncHandler

In asp.net, if I call a synchronous database request inside an IHttpAsyncHandler with a .BeginInvoke delegate, will it keep releasing the asp.net worker thread while reading the database?

For example, this post: http://madskristensen.net/post/How-to-use-the-IHttpAsyncHandler-in-ASPNET.aspx

If I put a synchronous database call inside ServeContent, will the request still be executed asynchronously?

0


a source to share


2 answers


No. And this is a misleading article, implying that she does it. To take advantage of it IHttpAsyncHandler

, you must call what responds asynchronously. For instance. a web service, an asynchronous database call (for example SqlCommand.BeginExecuteReader

), waking something up on a sleeping thread, etc.



TransmitFile

(which is used in the example article) is not asynchronous, it is synchronous. And it uses the worker thread just like any other synchronous call.

+1


a source


Looking at mysql's implementation of BeginExecuteReader, it only creates a delegate and calls BeginInvoke in the AsyncExecuteWrapper method, which just calls ExecuteReader. This does not seem correct to me, since it will only be a synchronous call inside the delegate. Thus, even if I use the BeginExecuteReader mysql connector inside the IHttpAsyncHandler, I won't work. Will it be?



Thanks.

0


a source







All Articles