private void RetryConnectToDB(object sender, EventArgs e) { DataBaseOperations.InitConnectionToDB(); if (DataBaseOperations.Connected) { TimerRetryConnectToDB.Close(); } }
public void StartServer() { DataTableDependeces.InitializeDependences(new DependencesInitializer()); DataBaseOperations.InitConnectionToDB(); if (!DataBaseOperations.Connected) { // нужно добавить дефолт RetryConnectionTime = int.Parse(ConfigurationManager.AppSettings.Get("RetryConnectionTime")); Console.WriteLine(RetryConnectionTime); Console.Read(); TimerRetryConnectToDB = new Timer(RetryConnectionTime); // 1 min TimerRetryConnectToDB.Elapsed += RetryConnectToDB; } new Listener().StartListen(); }