private static void Main() { var serviceHandler = new ServiceHandler(); if (Environment.UserInteractive) { serviceHandler.OnStart(null); Console.WriteLine("Service started! Press <ENTER> to terminate service."); Console.ReadLine(); serviceHandler.OnStop(); Console.WriteLine("Service stopped!"); return; } Run(serviceHandler); }