SyncOrchestrator.Synchronize 方法
啟動同步處理工作階段。
命名空間: Microsoft.Synchronization
組件: Microsoft.Synchronization (在 microsoft.synchronization.dll)
語法
'宣告
Public Function Synchronize As SyncOperationStatistics
'用途
Dim instance As SyncOrchestrator
Dim returnValue As SyncOperationStatistics
returnValue = instance.Synchronize
public SyncOperationStatistics Synchronize ()
public:
SyncOperationStatistics^ Synchronize ()
public SyncOperationStatistics Synchronize ()
public function Synchronize () : SyncOperationStatistics
傳回值
有關同步處理工作階段的統計資料。
備註
這個方法所執行的同步處理將是單向或雙向,端視 Direction 的值而定。
呼叫這個方法時,LocalProvider 或 RemoteProvider 都不可以是 null 參考 (在 Visual Basic 中為 Nothing)。
這個方法會將 State 設定為對應至 Direction 的值。
範例
下列範例會同步處理兩個提供者之間的資料,並向使用者顯示同步處理統計資料。
' Create the synchronization orchestrator and set the providers and synchronization direction.
Dim orchestrator As New SyncOrchestrator()
orchestrator.LocalProvider = localProvider
orchestrator.RemoteProvider = remoteProvider
orchestrator.Direction = syncDir
Dim msg As String
Try
' Synchronize data between the two providers.
Dim stats As SyncOperationStatistics = orchestrator.Synchronize()
' Display statistics for the synchronization operation.
msg = ((("Synchronization succeeded!" & vbLf & vbLf & stats.DownloadChangesApplied & " download changes applied" & vbLf) & stats.DownloadChangesFailed & " download changes failed" & vbLf) & stats.UploadChangesApplied & " upload changes applied" & vbLf) & stats.UploadChangesFailed & " upload changes failed"
Catch ex As Exception
msg = "Synchronization failed! Here's why: " & vbLf & vbLf & ex.Message
End Try
MessageBox.Show(msg, "Synchronization Results")
End Sub
// Create the synchronization orchestrator and set the providers and synchronization direction.
SyncOrchestrator orchestrator = new SyncOrchestrator();
orchestrator.LocalProvider = localProvider;
orchestrator.RemoteProvider = remoteProvider;
orchestrator.Direction = syncDir;
string msg;
try
{
// Synchronize data between the two providers.
SyncOperationStatistics stats = orchestrator.Synchronize();
// Display statistics for the synchronization operation.
msg = "Synchronization succeeded!\n\n" +
stats.DownloadChangesApplied + " download changes applied\n" +
stats.DownloadChangesFailed + " download changes failed\n" +
stats.UploadChangesApplied + " upload changes applied\n" +
stats.UploadChangesFailed + " upload changes failed";
}
catch (Exception ex)
{
msg = "Synchronization failed! Here's why: \n\n" + ex.Message;
}
MessageBox.Show(msg, "Synchronization Results");
}
請參閱
參考
SyncOrchestrator 類別
SyncOrchestrator 成員
Microsoft.Synchronization 命名空間