ASP.Net AJAX 和线程池
基于 ASP.Net 的 AJAX 请求是否使用与 ASP.Net 请求相同的 ThreadPool?
ASP.Net 异步编程使用不同的线程,将用于处理 ASP.Net 请求的线程返回到池中。
我想实现一个长时间运行的数据库搜索操作。
我正在考虑使用 AJAX webmethod。
但这里我有一个疑问:我是否需要使用异步范例在 webmethod 中实现此搜索操作?
如果 AJAX 请求也使用 ASP.Net ThreadPool,我只会采用异步方法。
请对此进行一些说明。
Do ASP.Net based AJAX requests use the same ThreadPool that ASP.Net requests use?
ASP.Net asynchronous programming uses a different thread, returning the thread used for processing ASP.Net requests to the pool.
I want to implement a long running DB search operation.
I am thinking about using an AJAX webmethod.
But here I have a doubt: Do I need to implement this search operation in a webmethod using the asynchronous paradigm?
I will only take an asynchronous approach if AJAX requests also use the ASP.Net ThreadPool.
Please throw some light on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这篇文章可能对你。
编辑:
我刚刚阅读了这篇文章并意识到你在问什么。
在执行异步任务时,ASP.Net 请求线程可以释放回线程池。您想知道 AJAX/异步回发是否也这样做。
我不明白他们为什么不这样做。毕竟,从服务器的角度来看,它们并没有那么特别 - 只是不是在响应中渲染整个页面,而是仅渲染页面的一部分。
您可能可以很容易地测试这一点 - 设置一个页面来触发异步回发中的缓慢异步任务。监视线程池中的可用线程数,并查看异步任务运行时线程数是否下降。确保您也在同步回发中测试它,作为控制。
I think this article might be of some use to you.
Edit:
I've just read this article and have realised what you're asking.
ASP.Net request threads can be released back into the threadpool while an asychronous task is being carried out. You want to know if AJAX/async-postbacks do this as well.
I don't see why they wouldn't. After all, they're not that special from the server's point of view - it's just that instead of rendering the whole page in the response only a part of the page is rendered.
You could probably test this easily enough - set up a page that triggers an slow asynchronous task in an async-postback. Monitor the number of available threads in the threadpool and see if it goes down while the asynchronous task is running. Make sure you test it in a synchronous postback too, as a control.