Print Page | Close Window

ExecuteAsync is not async

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2844
Printed Date: 28-Apr-2024 at 8:30am


Topic: ExecuteAsync is not async
Posted By: GeertvanHorrik
Subject: ExecuteAsync is not async
Date 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.




Replies:
Posted By: kimj
Date 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. 
 
 



Print Page | Close Window