Esempio n. 1
0
        static void Main(string[] args)
        {
            var service = new MyProductsService();

            if (args.Length == 0)
            {
                ServiceBase.Run(service);
            }
            else
            {
                var arg = args[0];

                try
                {
                    switch (arg)
                    {
                        case "--console":
                            RunInteractive(service, args);
                            break;
                        case "--install":
                            ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
                            break;
                        case "--uninstall":
                            ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
                            break;
                    }
                }
                catch (Exception)
                {
                    // TODO: logging...
                    throw;
                }
            }
        }
Esempio n. 2
0
        private static void RunInteractive(MyProductsService service, string[] args)
        {
            service.InteractiveStart(args);

            Console.WriteLine("myProducts Service running.");
            Console.WriteLine("Press Enter to Quit...");
            Console.ReadLine();

            service.InteractiveStop();
        }