Markus
Markus

Reputation: 3375

Examples on how to log the sync procedure

I have implemented a sync and it works fine. Since the sync is rather lengthy (in time) I want to create a ProgressBar that shows the progress of the sync. I have looked at some sync events, like ApplyingChanges.

However I'm not getting them as I expect, and the documentation isn't giving me much help either.

Does anyone have a link to some good examples on how the sync logging works? I would be very thankful.

(I'm using Sync framework 2.1)

For example, Isn't there any events between the ApplyingChanges and the ChangesApplied events?

Upvotes: 4

Views: 1029

Answers (1)

hwcverwe
hwcverwe

Reputation: 5367

Unfortunately I need to apologize that I cannot show code due to I am not working anymore for the project where we were using Microsoft Sync Framework 2.1. Hopefully the explanation will give you a step forward in the right direction.

In Microsoft Sync Framework 2.1 you have the ability to subscribe to the session progress event: Microsoft.Synchronization.SyncOrchestrator.SessionProgress. To be honest. i didn't get a reliable progress bar using this event. So I gathered the information by myself from the two sync providers.

I have only experience with the DatabaseSyncProvider (Which inherits RelationalSyncProvider) but hopefully helps you out.
A RelationalSyncProvider is raising some events which can help you out gathering information: See RelationalSyncProvider

Be aware that twoway synchronization means two sync sessions. Its recommended to calculate the progress for each sessions. So in case of bi-directional synchronization, once one session is completed, you are on 50 percent.

For more advanced progress bars, you need to know how many records you are going to synchronize. In combination with the gathered information from the events of the RelationalSyncProvider, you can build a quite accurate progressbar. For that you can just build a kind of preview, which is counting the changes which will be synchronized during the next session.
For that you can use the SyncKnowledge from the Target side and the selectchanges queries on the Source side database. The whereclause of the selectchanges queries, can be used for your own countchanges stored procedures. Due to you are using the same whereclause as MS Sync Framework is using to select changes, you will retrieve the exact amount of records which will be send synchronized for that session.

We are using this 'countchanges' not only for progress bars but also for statistics and advanced scheduling. If you are only going it for a progressbar you need to make a decision between performance penalty and a user friendly progressbar or having a less reliable progress bar.

Upvotes: 3

Related Questions