static void Main()
 {
     if (!Environment.UserInteractive)
     {
         var servicesToRun = new ServiceBase[] { new ListenerService() };
         Run(servicesToRun);
     }
     else
     {
         var runner = new ServiceRunner();
         runner.Start();
         Console.WriteLine("Press any key to stop service");
         Console.ReadLine();
         Console.WriteLine("Stopping");
         runner.Stop();
         Console.WriteLine("Stopped");
         Console.ReadLine();
     }
 }
 public ListenerService()
 {
     _serviceRunner = new ServiceRunner();
     InitializeComponent();
 }