'Declaration Public Event RecoverConnection As EventHandler(Of TdRecoveryEventArgs)
'Usage Dim instance As TdConnection Dim handler As EventHandler(Of TdRecoveryEventArgs) AddHandler instance.RecoverConnection, handler
public event EventHandler<TdRecoveryEventArgs> RecoverConnection
public: event EventHandler<TdRecoveryEventArgs^>^ RecoverConnection
The event handler receives an argument of type TdRecoveryEventArgs containing data related to this event. The following TdRecoveryEventArgs properties provide information specific to this event.
Property | Description |
---|---|
RecoveryTimeout | Application sets the timeout for recovery. |
The Data Provider will raise this event when starting reconnection and after subsequent attempts to reconnect. There is a delay period between reconnection attempts that is defined by TdConnectionStringBuilder.RecoveryStartInterval and modified by TdConnectionStringBuilder.RecoveryIntervalFactor. The event will be raised while there are active listeners.
Applications may subscribe to this event to change the initial TdConnectionStringBuilder.RecoveryTimeout value being supplied while the Data Provider is attempting to reconnect to the database. Applications may terminate reconnection attempt due to an excessive long wait by supplying a TdRecoveryEventArgs.RecoveryTimeout of 0 to the event.
After the first RecoveryTime is supplied and that time expires, the next RecoveryTimeout will be supplied as 0 by default unless a listener supplies a change to this value to extend the RecoveryTimeout again.
public void RecoveryEventExample(TdConnection cn) { TdCommand cmd = cn.CreateCommand(); cmd.CommandText = "Select col1 from TestTable"; // register an event handler for this event EventHandler<TdRecoveryEventArgs> recoveryEvent = new EventHandler<TdRecoveryEventArgs>(OnTimeoutExpired); cn.RecoverConnection += recoveryEvent; try { // read the results using (TdDataReader dr = cmd.ExecuteReader()) { String result; while (dr.Read() == true) { result = dr.GetString(0); Console.WriteLine(result); } } } finally { // unregister the event handler cn.RecoverConnection -= recoveryEvent; cn.Close(); } } public void OnTimeoutExpired(Object sender, TdRecoveryEventArgs args) { // assign additional time to complete reconnection args.RecoveryTimeout = 300; }
Product | Versions | Platforms |
---|---|---|
.NET | 6, 7 | Windows, Linux, MacOS |
.NET Framework | 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 | Windows |
.NET Standard | 2.0 | Windows, Linux, MacOS |