Asynchronous query

Thread is closed for posting
3 posts, 0 answers
  1. Maciej
    Maciej avatar
    7 posts
    Member since:
    Feb 2012

    Posted 30 Dec 2012 Link to this post


    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,
  2. Dimitar Tachev
    Dimitar Tachev avatar
    67 posts

    Posted 02 Jan 2013 Link to this post

    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.
  3. Neil
    Neil avatar
    1 posts
    Member since:
    Jul 2011

    Posted 01 Dec 2015 Link to this post

    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. 
Back to Top