共用方式為


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

  1. Register to handle the ApplyingChange event.

  2. Enable preview mode in the provider by setting the value of the PreviewMode property to true.

  3. Run synchronization and count the total number of times ApplyingChange is raised.

  4. Register to handle the AppliedChange event.

  5. Disable preview mode in the provider by setting the value of the PreviewMode property to false.

  6. 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

  1. Register to receive the IFileSyncProviderCallback::OnApplyingChange callback.

  2. Enable preview mode in the provider by passing TRUE to the IFileSyncProvider::SetPreviewMode method.

  3. Run synchronization and count the total number of times OnApplyingChange is called.

  4. Register to receive the IFileSyncProviderCallback::OnChangeApplied callback.

  5. Disable preview mode in the provider by passing FALSE to the IFileSyncProvider::SetPreviewMode method.

  6. 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.

請參閱

概念

Synchronizing Files

其他資源

IFileSyncProviderCallback interface