views:

278

answers:

2

Did anyone hear about asynchronous executing of an EF query?

I want my items control to be filled right when the form loads and the user should be able to view the list while the rest of the items are still being loaded.

Maybe by auto-splitting the execution in bulks of items (i.e. few queries for each execution) all in same connection.

Any ideas/suggestions/knowledge are welcommed.

I posted a feature suggestion to Microsoft, please share them with your ideas as well.

A: 

I take from your link that this is a web app. Is that correct?

A Query must complete and return data before rendering can begin. An EF feature will not help you here. Rather. look at breaking up your process into several processes that can be done at once.

Keep in mind that ASP.NET cannot return a response to a browser if it is not done rendering the HTML.

Let me assume you are executing a single query, getting the results back and displaying them to a page.

Best option: Page your results. if you Have 4000 records, show the first 50. If you show 200+ records to a user, They cannot digest that much information.

If that does not fit your needs, look at firing one query for 50 results. Make an Ajax call to the the remaining records and build the UI from there, in (reasonably sized) chunks.

brian chandley
I was talking about win apps, thanks for sharing your knowledge, it was indeed helpful.
Shimmy
EF support for async operations is still of value - the thread processing the current request can be returned to the thread pool to handle other requests while we wait on our async database call. But you are correct that this wouldn't speed up the user's perception of how fast the page loads.
Joel Mueller
+1  A: 

Not wanting to sound like a commercial, but I noticed that the latest DevExpress grid gives features like this in their WPF grid. Essentially you want to load visible-count items first, then load the rest in a background thread so your UI isn't freezing up. The background thread should probably load another page at a time and make them available to the UI thread.

It's something you would want to think about carefully and make sure you get it right, or simply buy a control that does the hard work for you.

Timothy Walters
Background thread!That's the word.
Shimmy