RelationalSyncProvider.DbConnectionFailure Event

Occurs when the database connection fails during change application.

Namespace:  Microsoft.Synchronization.Data
Assembly:  Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)

public event EventHandler<DbConnectionFailureEventArgs> DbConnectionFailure

This event can be used to override the default action taken when a database connection is throttled on a shared system, such as SQL Azure. The synchronization application can register to handle this event and can decide whether to retry the transaction or cancel synchronization.

The following example shows the DbConnectionFailure event handler. This event handler checks the number of retry attempts and overrides the default to retry the change application 10 times before stopping synchronization.

static void HandleDbConnectionFailure(object sender, DbConnectionFailureEventArgs e)
    // Override the default to retry 10 times before fail.
    if (e.RetryCount < 10)
        e.Action = DbConnectionFailureAction.RetrySync;
        e.Action = DbConnectionFailureAction.AbortSync;

Private Shared Sub HandleDbConnectionFailure(ByVal sender As Object, ByVal e As DbConnectionFailureEventArgs)
    ' Override the default to retry 10 times before fail.
    If e.RetryCount < 10 Then
        e.Action = DbConnectionFailureAction.RetrySync
        e.Action = DbConnectionFailureAction.AbortSync
    End If
End Sub