Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » MobiLink - 客户端管理 » 用于 MobiLink 的 SQL Anywhere 客户端 » Dbmlsync 集成组件(不建议使用) » Dbmlsync 集成组件的事件

 

EndSynchronization 事件

在同步完成时,会触发 EndSynchronization 事件。

语法
Public Event EndSynchronization(
  ByVal exitCode As Integer,
  ByRef restart As Boolean
)
Member of DbmlsyncCOM.Dbmlsync
参数

exitCode   设置为 0 以外的任何值时,则表示发生了同步错误。

restart   调用该事件时,会将此值设置为 false。如果事件将其值更改为 true,dbmlsync 会重新启动同步。

注释

您可以使用此事件在同步完成时添加自定义操作。

示例

以下 Visual Basic .NET 示例使用 EndSynchronization 事件重新启动最多 5 次失败的同步尝试。如果所有重新启动尝试均告失败,则输出 "All restart attempts failed" 和退出代码。如果同步成功,则输出消息 "同步成功" 和退出代码。

' Global variable for the number of restarts
Dim numberOfRestarts As Integer

Private Sub dbmlsync1_EndSynchronization(
 ByVal ExitCode As Integer,
 ByRef restart As Boolean
)
Handles dbmlsync1.EndSynchronization

    If numberOfRestarts < 5 Then
        MsgBox("Restart Number: " + CStr(numberOfRestarts + 1))
        If ExitCode <> 0 Then
            ' restart the failed synchronization
            restart = True
            numberOfRestarts = numberOfRestarts + 1
        Else
            ' the last synchronization succeeded
            MsgBox("Synchronization succeeded. " + _
              "Exit code: " + CStr(ExitCode))
        End If
    Else
        MsgBox("All restart attempts failed. " + _
             "Exit code: " + CStr(ExitCode))
    End If

End Sub