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()
member Synchronize : unit -> SyncOperationStatistics
public function Synchronize() : SyncOperationStatistics
戻り値
型 : Microsoft.Synchronization. . :: . .SyncOperationStatistics
同期セッションに関する統計情報です。
例外
例外 | 条件 |
---|---|
InvalidOperationException |
または
|
説明
このメソッドが実行する同期は、Direction の値に応じて、一方向または双方向で行われます。
このメソッドが呼び出されると、LocalProvider にも RemoteProvider にも null Nothing nullptr unit NULL 参照 (Visual Basic では Nothing) を指定できません。
このメソッドは、Direction の値に対応するように、State を設定します。
例
次の例では、2 つのプロバイダーの間でデータを同期し、同期統計情報をユーザーに示します。
' 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");
}