mardi 20 janvier 2009 10:00
I'm looking into whether or not the actual Syncing can be done asynchronously. I have a book (Apress Pro Sync Framework, Singh/Kanjilal) which shows the SyncCallbacks class, along with the callback methods (including OnProgressChanged which is ideal for monitoring the progress of long running syncs) but does not show how to implement it.
Also, if I look for this class in Sync Services for Devices (compact framework) I cannot find it. My sync client is a smart device application running on Windows Mobile 6.
How would I go about implementing an asynchronous Sync, and can I obtain callbacks to monitor the progress of the sync?
Many thanks in advance.
- Déplacé Max Wang_Chinasoft jeudi 21 avril 2011 22:29 forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
Toutes les réponses
mercredi 21 janvier 2009 20:21
I am not aware of out of the box asynch methods being part of the sync provider. I ended up writing my own. It was pretty easy. Just create a class called SyncManager for example. Instead of calling the synchronize method directly, run your calls through your SyncManager class. This class will contain a background worker which dispatches the calls to Synchronize. Problem solved, now you synchronization occurrs on another thread. Just make sure to invoke your calls to your UI when handling a synch event.
As for the progress events, there are tons of examples of using them on this website. http://www.syncguru.com/Default.aspx
dimanche 25 janvier 2009 08:32Modérateur
right. the out of box sync service doesn support async sync. but you can do this in the application level as described in this thread.
vendredi 31 juillet 2009 16:30Hi,
I'm bumping this threading as I'm now at the stage in my project where I need to implement this.
OverloadedOverrides, thanks for the link - I followed it but couldn't find the information you mentioned though.
Yunwen, thanks for clarifying that it isn't supported out-of-the-box - you mentioned doing it at the application level "as described in this thread" but there's no thread link.
Any more help you can give would be gratefully appreciated.
samedi 1 août 2009 07:40I think he was referring to the second post (above). You need to create a separate class which acts as a 'Sync Manager' to perform the sync. Within that class, have a method which spawns a new background thread. The new thread makes the call to SyncAgent->Synchronize.
/// Update cache asynchronously
public void UpdateCacheAsync()
if (IsSyncing == false)
IsSyncing = true; // reset the IsSyncing flag to indicate sync is in progress (don't want multi-instance of sync)
thr = new Thread(new ThreadStart(this.Sync));
thr.IsBackground = true;
/// Sync the data
private void Sync()
SyncAgent syncAgent = this.GetSyncAgent();
SyncStatistics stats = syncAgent.Synchronize();
catch (Exception ex)
- Marqué comme réponse PaulMcMurray mardi 4 août 2009 14:32
mardi 4 août 2009 14:32Thanks SunHunter - I've got it working now!
lundi 5 octobre 2009 14:30Sunhunter, could you post your SyncManager class ? I read about it in this thread (http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/aba12aa1-6183-419a-af7c-0446e004f6cb/), but apparently am missing something.
In my code, I init a SyncAgent, and specify some LocalProvider events and properties. Then I pass the syncagent to the SyncManager.
I get a CientConnection is null error. If I sync without the syncManager, it is fine.
- Fusionné Liam Cavanagh - MSFTMicrosoft Employee, Owner mardi 1 décembre 2009 19:38 Linked to this thread
mardi 1 décembre 2009 20:48
Thanks SunHunter - I've got it working now!Paul - Care to share an example ?