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.