using System; using System.Diagnostics; using System.ServiceProcess; namespace HAILogger { class Program { static CoreServer server; static void Main(string[] args) { for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "-c": Global.dir_config = args[++i]; break; } } if (Environment.UserInteractive) { Console.TreatControlCAsInput = false; Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); server = new CoreServer(); } else { ServiceBase[] ServicesToRun; // More than one user Service may run within the same process. To add // another service to this process, change the following line to // create a second service object. For example, // // ServicesToRun = new ServiceBase[] {new Service1(), new MySecondUserService()}; // ServicesToRun = new ServiceBase[] { new Service() }; ServiceBase.Run(ServicesToRun); } } protected static void myHandler(object sender, ConsoleCancelEventArgs args) { server.Shutdown(); args.Cancel = true; } } }