/// <summary> /// Handles a failed connection to a server. /// This method can be overrided to implement a custom failover handling /// </summary> /// <param name="server">The failed server</param> internal protected virtual void HandleFailover(ReplicationServer server) { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate(object sender, DoWorkEventArgs e) { bool isRunning = false; ReplicationServer server1 = e.Argument as ReplicationServer; #if !RT System.Timers.Timer timer = new System.Timers.Timer(RetryTime * 1000.0); System.Timers.ElapsedEventHandler elapsedEvent = delegate(object sender1, System.Timers.ElapsedEventArgs e1) { if (isRunning) { return; } try { isRunning = true; using (MySqlConnection connectionFailed = new MySqlConnection(server.ConnectionString)) { connectionFailed.Open(); server1.IsAvailable = true; timer.Stop(); } } catch { MySqlTrace.LogWarning(0, string.Format(Properties.Resources.Replication_ConnectionAttemptFailed, server1.Name)); } finally { isRunning = false; } }; timer.Elapsed += elapsedEvent; timer.Start(); elapsedEvent(sender, null); #else Windows.UI.Xaml.DispatcherTimer timer = new Windows.UI.Xaml.DispatcherTimer(); TimeSpan ts = new TimeSpan(RetryTime * 1000); System.EventHandler <object> elapsedEvent = (TickSender, TickEventArgs) => { if (isRunning) { return; } try { isRunning = true; using (MySqlConnection connectionFailed = new MySqlConnection(server.ConnectionString)) { connectionFailed.Open(); server1.IsAvailable = true; timer.Stop(); } } catch { MySqlTrace.LogWarning(0, string.Format(Properties.Resources.Replication_ConnectionAttemptFailed, server1.Name)); } finally { isRunning = false; } }; timer.Tick += elapsedEvent; elapsedEvent(sender, null); timer.Start(); #endif }; worker.RunWorkerAsync(server); }