예제 #1
0
        private static void RunInteractive(string[] args)
        {
            var testService = new AppWin32Service(args.Where(a => a != InteractiveFlag).ToArray());

            testService.OnStart += Start;
            testService.OnStop  += Stop;

            logger.Info("Running as console application");
            try
            {
                testService.Start(new string[0], () => { });
                if (CheckConsole())
                {
                    logger.Info("Press any key to stop...");
                    Console.ReadKey(true);
                }
            }
            catch (Exception ex)
            {
                ShowUnhandledException(ex);
            }
            finally
            {
                testService.Stop();
                if (CheckConsole())
                {
                    logger.Info("Press any key to exit");
                    Console.ReadKey();
                }
            }
        }
예제 #2
0
        private static void RunAsService(string[] args)
        {
            logger.Info("Running as service");
            var testService = new AppWin32Service(args.Where(a => a != RunAsServiceFlag).ToArray());

            testService.OnStart += Start;
            testService.OnStop  += Stop;
            var serviceHost = new Win32ServiceHost(testService);

            serviceHost.Run();
        }