locked
Sync services as Background work RRS feed

  • Question

  • Document available at http://msdn.microsoft.com/en-us/sync/bb887608.aspx says that "With Sync Services for ADO.NET, synchronization can run as a background thread. As long as the local database supports the ability to synchronize on a separate connection (as SQL Server Compact does), synchronization can be executed in the background. This allows a local user to continue to use and change their database while synchronization is being completed." How true is this?

     

    I've an Hub-spoke model sync setup based on SqlExpress provider samples provided by MSF team. When syncing I might have 1000s of rows to be updated to either server or client. Through out the sync process related tables seems to be locked out. How to make syncing truly a background work, so that my users can work while sync runs in the background?

     

    • Moved by Hengzhe Li Friday, April 22, 2011 8:04 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, September 24, 2008 5:36 AM

Answers

  • During sync, all changes in the same sync group are taken care of by one transaction.  Therefore if you have thousands of changes in one transaction, I think SQL server will escalate row/page level lock to a table level lock.  And this is what you have seen.

     

    One alternative is to limit the number of changes during the sync.  Please refer to the batching support from www.syncguru.com.  However this batching support works for download sync only.

     

    Another suggestion is to do more frequent sync on schedule so that the system won't accumulate 1000s changes from sync to sync.

     

    Thanks.

    Wednesday, September 24, 2008 8:56 PM
    Answerer
  • Is there a way to keep this process/application alive while the PDA enters power saving mode?

     

    To follow up this thread, I have implimented a background application that sync's on a timer.  It works well but when the device enter's power saving mode the sync stops mid-way, or wont start the sync.
    Monday, October 13, 2008 4:13 AM
  • You could try calling SystemIdleTimerReset() every standby interval (from registry) while syncing.

    Monday, October 13, 2008 7:37 AM
  • Thankyou, your comment led me to some exellent references!!! 

     

    I can put this in my _SessionProgress event to keep the PDA alive during sync :

    http://www.pinvoke.net/default.aspx/coredll/SystemIdleTimerReset.html

     

    I can now wake up the PDA on a interval and sync the PDA, alerting the user of any new jobs/information :

    http://msdn.microsoft.com/en-us/library/ms913957.aspx

    and

    http://www.koushikdutta.com/2008/07/cerunappattime-cesetusernotificationex.html

     

    More than enough reading material here to achieve my goal, thanks again.

    Tuesday, October 14, 2008 12:03 AM

All replies

  • During sync, all changes in the same sync group are taken care of by one transaction.  Therefore if you have thousands of changes in one transaction, I think SQL server will escalate row/page level lock to a table level lock.  And this is what you have seen.

     

    One alternative is to limit the number of changes during the sync.  Please refer to the batching support from www.syncguru.com.  However this batching support works for download sync only.

     

    Another suggestion is to do more frequent sync on schedule so that the system won't accumulate 1000s changes from sync to sync.

     

    Thanks.

    Wednesday, September 24, 2008 8:56 PM
    Answerer
  • Is there a way to keep this process/application alive while the PDA enters power saving mode?

     

    To follow up this thread, I have implimented a background application that sync's on a timer.  It works well but when the device enter's power saving mode the sync stops mid-way, or wont start the sync.
    Monday, October 13, 2008 4:13 AM
  • You could try calling SystemIdleTimerReset() every standby interval (from registry) while syncing.

    Monday, October 13, 2008 7:37 AM
  • Thankyou, your comment led me to some exellent references!!! 

     

    I can put this in my _SessionProgress event to keep the PDA alive during sync :

    http://www.pinvoke.net/default.aspx/coredll/SystemIdleTimerReset.html

     

    I can now wake up the PDA on a interval and sync the PDA, alerting the user of any new jobs/information :

    http://msdn.microsoft.com/en-us/library/ms913957.aspx

    and

    http://www.koushikdutta.com/2008/07/cerunappattime-cesetusernotificationex.html

     

    More than enough reading material here to achieve my goal, thanks again.

    Tuesday, October 14, 2008 12:03 AM