Compartir a través de


Synchronize Método

Inicia una sesión de sincronización.

Espacio de nombres:  Microsoft.Synchronization
Ensamblado:  Microsoft.Synchronization (en Microsoft.Synchronization.dll)

Sintaxis

'Declaración
Public Function Synchronize As SyncOperationStatistics
'Uso
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

Valor devuelto

Tipo: Microsoft.Synchronization. . :: . .SyncOperationStatistics
Estadísticas sobre la sesión de sincronización.

Excepciones

Excepción Condición
InvalidOperationException

o bien

  • La propiedad LocalProvider o la propiedad RemoteProvider es un valor null Nothing nullptr unit es una referencia NULL (Nothing en Visual Basic). .

Notas

La sincronización que este método realiza será unidireccional o bidireccional, dependiendo del valor de Direction.

Cuando se llama a este método, ni LocalProvider ni RemoteProvider pueden ser un valor NULL.

Este método establece State en un valor que se corresponde con el valor de Direction.

Ejemplos

En el ejemplo siguiente se sincronizan datos entre dos proveedores y se muestran al usuario las estadísticas de sincronización.

    ' 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");
}

Vea también

Referencia

SyncOrchestrator Clase

SyncOrchestrator Miembros

Microsoft.Synchronization Espacio de nombres