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();
     }
 }
 /// <summary>
 /// Set things in motion so your service can do its work.
 /// </summary>
 protected override void OnStart(string[] args)
 {
     _serviceRunner.Start();
 }