none
Multi-threaded background sync RRS feed

  • Question

  • I've started playing around with the Sync Framework (just through the generated Local Database Cache in VS2010) to do bi-directional sync and I've not been able to find any definitive answer on whether it's safe to insert/update the local database cache during a bi-directional sync.

    Here's what I've got:

    • Application written in C# using WPF 4.0
    • Using Entity Framework 4.0 for data access
    • Doing bi-directional sync using the VS2010 'Local Database Cache' against an SQL Server Express instance
    • Several tables are being synced, some are bi-directional, some download-only and some upload-only

    What I'm currently doing is I create the SyncAgent in my app object's OnStartup handler and keep this single instance of the SyncAgent for the lifetime of the application.  After initial creation, the SyncAgent is only access from a single background thread that periodically performs a sync.

    • Is it safe for me to insert/update to the local database cache?
    • There are relationships between the tables that are enforced on the server, is there any chance of sync fx trying to upload changes for one table but not the other if those changes occur in the middle of a sync?
    • What happens if a row being synced is updated during the sync?

    I've not yet finished implementing this so haven't really had a chance to test any of this out to see what happens, but if there are likely to be issues it'd be nice to know about them before hand :)

     

    Thanks.

    Tuesday, November 16, 2010 9:31 AM