/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { var service = new Main(); if (Debugger.IsAttached) { RunInteractive(service, args); } else if (args.Any()) { switch (string.Concat(args).ToLower()) { case "--console": RunInteractive(service, args); break; case "--install": InstallService(); break; case "--uninstall": UninstallService(); break; case "--start": StartService(); break; case "--stop": StopService(); break; default: DisplayHelpMessage(); break; } } else { if (Environment.UserInteractive) { DisplayHelpMessage(); } else { ServiceBase.Run(service); } } }
private static void RunInteractive(Main service, string[] args) { service.InteractiveStart(args); Console.WriteLine(ConsoleStopMessage); Console.Read(); service.InteractiveStop(); }