Reporting File Synchronization Progress
An application can track synchronization progress by registering to receive notifications that occur during synchronization.
Managed code Register handlers to receive events from the FileSyncProvider object, such as CopyingFile, which occurs periodically to show progress while a file is being copied; or AppliedChange, which occurs when a file change has been applied.
Unmanaged code Pass an IFileSyncProviderCallback object to the IFileSyncProvider::Initialize method. The IFileSyncProviderCallback methods are called when events are raised, such as IFileSyncProviderCallback::OnFileCopyProgress, which occurs periodically to show progress while a file is being copied; or IFileSyncProviderCallback::OnChangeApplied, which occurs when a file change has been applied.
Preview Mode
The application can put the provider in preview mode by setting the value of the PreviewMode property to true (for managed code) or by passing TRUE to the IFileSyncProvider::SetPreviewMode method (for unmanaged code) before it starts synchronization. While in preview mode, the provider detects changes and raises events in the same way as during a typical synchronization session. However, the provider does not actually apply any changes to the destination replica and does not send the AppliedChange event (for managed code) or IFileSyncProviderCallback::OnChangeApplied event (for unmanaged code).
Showing Incremental Progress
To show incremental progress during a synchronization session, use the following procedures.
Managed code
Register to handle the ApplyingChange event.
Enable preview mode in the provider by setting the value of the PreviewMode property to true.
Run synchronization and count the total number of times ApplyingChange is raised.
Register to handle the AppliedChange event.
Disable preview mode in the provider by setting the value of the PreviewMode property to false.
Run synchronization. When AppliedChange is raised, synchronization progress can be incremented toward the total number of changes that were calculated when synchronization was run in preview mode.
Unmanaged code
Register to receive the IFileSyncProviderCallback::OnApplyingChange callback.
Enable preview mode in the provider by passing TRUE to the IFileSyncProvider::SetPreviewMode method.
Run synchronization and count the total number of times OnApplyingChange is called.
Register to receive the IFileSyncProviderCallback::OnChangeApplied callback.
Disable preview mode in the provider by passing FALSE to the IFileSyncProvider::SetPreviewMode method.
Run synchronization. When OnChangeApplied is called, synchronization progress can be incremented toward the total number of changes that were calculated when synchronization was run in preview mode.
See Also
Reference
IFileSyncProviderCallback Interface