Ejemplo n.º 1
0
 public static void Main(string[] args)
 {
     if (!System.Environment.UserInteractive)
     {
         // run as windows service
         _log.Info("Starting Windows Service...");
         ServiceBase[] servicesToRun = new ServiceBase[] { new MyWindowsService() };
         ServiceBase.Run(servicesToRun);
     }
     else
     {
         // run as console app
         _log.Info("Starting ConsoleHost......");
         ServiceHosts.Open();
         _log.Info("Press 'Q' to quit.");
         while (Console.Read() != (int)'Q')
         {
             System.Threading.Thread.Sleep(1000);
         }
         ServiceHosts.Close();
     }
 }
Ejemplo n.º 2
0
 protected override void OnStop()
 {
     ServiceHosts.Close();
 }