ASP.NET的WebMethod持有线程池线程上长时间运行的SQL过程 [英] ASP.NET WebMethod holding threadpool thread on long running SQL procedure

查看:254
本文介绍了ASP.NET的WebMethod持有线程池线程上长时间运行的SQL过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从建立一个数据库表的报表报表页面。该报告显示在一个表格格式。为了处理用户交互我已经建立了一个jQuery插件表,允许用户定制自己的自定义排序,筛选和分页报告。

的jQuery插件使用了一组Ajax请求的填充表数据。这些Ajax请求调用asp.net(C#)webMethods的,后者又使用一组类来建立SQL并执行查询。内置的查询可以在同一个线程中的WebMethod这会导致一个问题,因为SQL可以在超过30秒后返回运行。我一直在阅读有关启动新的线程和异步方法。我的问题是我显然不想从ASP.NET池用于SQL的整个执行举行一个线程,因为它只是在等待I / O。

是否有可能该线程返回线程池在等待从SQL Server响应?这可以使用开始和结束ADO.net命令能实现吗?

我想问的原因是目前这不是一个问题,而是使用该系统的用户数量增加了服务的所有新用户的线程池会运行这些长查询饱和。


解决方案

  

这可以使用开始和结束ADO.net命令能实现吗?


没错!

I have a reporting page which builds a report from a database table. The report is displayed in a tabular format. To handle user interactions I have built a JQuery table plugin which allows a user to customize their report with custom sorting, filtering and paging.

The JQuery plugin uses a set of ajax requests to populate the table with data. These ajax requests call asp.net (c#) webMethods which in-turn uses a set of classes to build SQL and execute the Query. The Queries built are run in the same thread as the WebMethod this causes a problem because the SQL can take in excess of 30 seconds to return. I have been reading about starting new threads and the asynchronous approach. My problem is I obviously don't want to hold a thread from the ASP.NET pool for the entire execution of the SQL as it is only waiting for I/O.

Is it possible to return the thread to the threadpool while waiting for the response from the SQL Server? Can this be achieved using the Begin and End ADO.net commands?

The reason I ask is at the moment this is not a problem but as the number of users using this system increases all the threadpool serving new users will be saturated running these long queries.

解决方案

Can this be achieved using the Begin and End ADO.net commands?

Exactly!

这篇关于ASP.NET的WebMethod持有线程池线程上长时间运行的SQL过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆