New Posts New Posts RSS Feed: ExecuteAsync is not async
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

ExecuteAsync is not async

 Post Reply Post Reply
Author
GeertvanHorrik View Drop Down
Newbie
Newbie


Joined: 23-Jun-2011
Posts: 6
Post Options Post Options   Quote GeertvanHorrik Quote  Post ReplyReply Direct Link To This Post Topic: ExecuteAsync is not async
    Posted: 25-Jul-2011 at 12:45am
Hello,

We are using DevForce and have a question regarding the cache and asynchronous behaviors. We have created a grid view and loading customers into the grid. The first time, it all works like a charm and the UI stays responsive during the retrieval of the data.

However, the 2nd time when we refresh the grid (and execute the same query, just a select all), the UI freezes for a bit (2 or 3 seconds). What seems, if we change the query strategy, the issue goes away:

_manager.DefaultQueryStrategy = new QueryStrategy(FetchStrategy.DataSourceOnly, MergeStrategy.OverwriteChanges);

However, this solution is not acceptable because this requires the user to retrieve all data from the database instead of the local cache.

Our question is: is there a way to truly execute the query async and let the cache determination be async as well.


Thanks in advance.

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1390
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jul-2011 at 9:15am
There are two parts to an async query:  the actual query execution where the request is sent to the server and the results are received, and the merge of these results into cache.  The first part is always performed on a background thread, the second part, the merge into cache, is always performed synchronously on the main thread.  The merge must be performed synchronously because the EntityManager itself is not thread safe, and you may have other queries, saves or edits underway.  The merge might be slow if a large number of entities of the queried type are already loaded into cache.  As the merge is performed a number of events can be fired too, so if you have handlers in place, such as PropertyChanged, EntityChanged, EntityGroupChanged, that could affect performance. 
 
Generally, if you re-execute exactly the same query when using the "Normal" query strategy the EntityManager will run a CacheOnly query.  Even when called via ExecuteAsync the CacheOnly query will complete synchronously, and since the actual cache contents haven't changed no merge is performed and this should be fast.  If you're doing a CacheOnly query and seeing the UI freeze then the problem may be in how you're re-loading the collection or performing the data binding. 
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down