DbConnectionFailure 事件
套用變更期間資料庫連接失敗時發生。
命名空間: Microsoft.Synchronization.Data
組件: Microsoft.Synchronization.Data (在 Microsoft.Synchronization.Data.dll 中)
語法
'宣告
Public Event DbConnectionFailure As EventHandler(Of DbConnectionFailureEventArgs)
'用途
Dim instance As RelationalSyncProvider
Dim handler As EventHandler(Of DbConnectionFailureEventArgs)
AddHandler instance.DbConnectionFailure, handler
public event EventHandler<DbConnectionFailureEventArgs> DbConnectionFailure
public:
event EventHandler<DbConnectionFailureEventArgs^>^ DbConnectionFailure {
void add (EventHandler<DbConnectionFailureEventArgs^>^ value);
void remove (EventHandler<DbConnectionFailureEventArgs^>^ value);
}
member DbConnectionFailure : IEvent<EventHandler<DbConnectionFailureEventArgs>,
DbConnectionFailureEventArgs>
備註
這個事件可用來覆寫在共用系統上 (例如 SQL Azure) 設定資料庫連接節流時所採取的預設動作。可以註冊同步處理應用程式來處理這個事件,而且可以決定是否要重試交易或取消同步處理。
範例
以下範例示範 DbConnectionFailure 事件處理常式。此事件處理常式會檢查重試的次數並覆寫預設值,重試變更套用 10 次之後再停止同步處理。
static void HandleDbConnectionFailure(object sender, DbConnectionFailureEventArgs e)
{
// Override the default to retry 10 times before fail.
if (e.ApplyTransactionRetry < 10)
{
e.Action = DbConnectionFailureAction.Retry;
}
else
{
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.ApplyTransactionRetry < 10 Then
e.Action = DbConnectionFailureAction.Retry
Else
e.Action = DbConnectionFailureAction.AbortSync
End If
End Sub
請參閱
參考
Microsoft.Synchronization.Data 命名空間