0

On asp.net if i call a synchronous database query inside an IHttpAsyncHandler with delegate.BeginInvoke, would it still release 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, would the request still happen asynchronously?

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164

2 Answers2

1

No. And that's a misleading article to imply that it does. In order to get the benefits of IHttpAsyncHandler you must call something that responds asynchronously. E.g. a web service, asynchronous database call (such as SqlCommand.BeginExecuteReader), waking up something in a sleeping thread, etc.

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

Keltex
  • 26,220
  • 11
  • 79
  • 111
0

Looking at the mysql implementation of BeginExecuteReader, it only creates a delegate and call BeginInvoke on the AsyncExecuteWrapper method, which just calls ExecuteReader. This does not seem right to me, as it will only be a synchronous call inside a delegate. So, even if i use the mysql connector BeginExecuteReader inside a IHttpAsyncHandler i won't work. Would it?

Thanks.