This is a migrated thread and some comments may be shown as answers.

Asynchronous query

2 Answers 193 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Maciej
Top achievements
Rank 1
Maciej asked on 30 Dec 2012, 02:25 PM
Hello,

In my application I get about 2000 records from database and it takes same time (in this time application is "hanging"). Is possible to execute asynchronous query using openAccess.

Best Regards,
Maciej

2 Answers, 1 is accepted

Sort by
0
Dimitar Tachev
Telerik team
answered on 02 Jan 2013, 04:06 PM
Hi Maciej,

Executing an asynchronous query using OpenAccess is not currently supported out of the box and in order to select records in asynchronous way I suggest you the following options:

  1. Use an asynchronous Task – choosing this approach you will have control how the task will be executed and scheduled by the thread pool, you will be able to cancel already started tasks and you can easily specify what are the next steps after the task is complete.  
  2. Use the ThreadPool – this approach offers a simpler implementation if you need to run a few independent queries and has slightly better performance. But you will have to define events in order to chain several queries together if your scenario requires so.

For your convenience I prepared a sample application using the Northwind database demonstrating how to extend the IQueryable<T> interface with asynchronous extension methods for the above-mentioned scenarios – you could find it attached.

Please bear in mind that you should not dispose the context before you are sure that all of the asynchronous operations have finished. Otherwise the remaining queries will fail.

Also we listed a feature request for supporting asynchronous queries out of the box. You can vote for it in our new Ideas & Feedback Portal and track its progress. If this appears to be a common request, you may see it included in a future version of the OpenAccess ORM.

I hope this helps.

Kind regards,
Dimitar Tachev
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Neil
Top achievements
Rank 1
answered on 01 Dec 2015, 11:13 AM
I know you can use Task.Run or Task.StartFactory but this has thread creation and management overhead; performance will be degraded as the number of threads increases. 
Tags
General Discussions
Asked by
Maciej
Top achievements
Rank 1
Answers by
Dimitar Tachev
Telerik team
Neil
Top achievements
Rank 1
Share this question
or