Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DbStatus
- {
- public static bool DbOnline()
- {
- const int MaxRetries = 10;
- int count = 0;
- while (count < MaxRetries)
- {
- try
- {
- // Just access the database. any cheap query is ok since we don't care about the result.
- return true;
- }
- catch (Exception ex)
- {
- Thread.Sleep(30000);
- count++;
- }
- }
- return false;
- }
- }
- processInstaller.Account = ServiceAccount.LocalSystem;
- processInstaller.Username = null;
- processInstaller.Password = null;
- using (ServiceInstaller installer = new ServiceInstaller())
- {
- installer.DisplayName = "yourservice.";
- installer.StartType = ServiceStartMode.Automatic;
- installer.ServiceName = "YourService";
- installer.ServicesDependedOn = new string [] { "DependenceService" };
- this.Installers.Add(processInstaller);
- this.Installers.Add(installer);
- }
Add Comment
Please, Sign In to add comment