Beispiel #1
0
        // Run a service from the console given a service implementation
        internal static void Run(string[] args, IWindowsService service)
        {
            string serviceName = service.GetType().Name;
            bool   isRunning   = true;

            // simulate starting the windows service
            // bypass the system event call via ServiceBase and go straight to our handler
            if (service.OnStart(args, new EventLog(true)))
            {
                // let it run as long as Q is not pressed
                while (isRunning)
                {
                    WriteToConsole(ConsoleColor.Yellow, "\nEnter either [P]ause, [R]esume, [Q]uit (stop), [S]hutdown: ");
                    isRunning = HandleConsoleInput(service, WaitForKey(false));
                }

                if (shutdown)
                {
                    service.OnShutdown();
                }
                else
                {
                    service.OnStop();
                }
            }

            WaitForKey(true);
        }
Beispiel #2
0
        // Run a service from the console given a service implementation
        public static void Run(string[] args, IWindowsService service)
        {
            bool isRunning = true;

            // simulate starting the windows service
            service.OnStart(args);

            // let it run as long as Q is not pressed
            while (isRunning)
            {
                WriteToConsole(ConsoleColor.Yellow, "Enter either [Q]uit, [P]ause, [R]esume : ");
                isRunning = HandleConsoleInput(service, Console.ReadLine());
            }

            // stop and shutdown
            service.OnStop();
            service.OnShutdown();
        }
        // Run a service from the console given a service implementation
        public static void Run(string[] args, IWindowsService service)
        {
            string serviceName = service.GetType().Name;
            bool isRunning = true;

            // simulate starting the windows service
            service.OnStart(args);

            // let it run as long as Q is not pressed
            while (isRunning)
            {
                WriteToConsole(ConsoleColor.Yellow, "Enter either [Q]uit, [P]ause, [R]esume : ");
                isRunning = HandleConsoleInput(service, Console.ReadLine());
            }

            // stop and shutdown
            service.OnStop();
            service.OnShutdown();
        }
Beispiel #4
0
        // Run a service from the console given a service implementation
        public static void Run(string[] args, IWindowsService service)
        {
            string serviceName = service.GetType().Name;
            bool   isRunning   = true;

            // simulate starting the windows service
            service.OnStart(args);

            // let it run as long as Q is not pressed
            while (isRunning)
            {
                WriteToConsole(ConsoleColor.Yellow, "Choisir [Q]uitter, [P]ause, [R]eprendre : ");
                isRunning = HandleConsoleInput(service, Console.ReadLine());
            }

            // stop and shutdown
            service.OnStop();
            service.OnShutdown();
        }
Beispiel #5
0
        /// <summary>
        /// Runs the service that implements <see cref="IWindowsService" />.
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <param name="service">The service.</param>
        public static void Run(string[] args, IWindowsService service)
        {
            var serviceName = service.GetType().Name;

            WriteToConsole(ConsoleColor.Green, serviceName);
            WriteToConsole(ConsoleColor.Yellow, "Enter either [Q]uit, [P]ause, [R]esume : ");

            var running = true;

            service.OnStart(args);

            while (running)
            {
                running = ReadConsoleInput(service, Console.ReadKey(true).Key.ToString());
            }

            service.OnStop();
            service.OnShutdown();
        }
        // Run a service from the console given a service implementation
        public static void Run(string[] args, IWindowsService service)
        {
            string serviceName = service.GetType().Name;
            bool   isRunning   = true;

            // simulate starting the windows service
            service.OnStart(args);

            // let it run as long as Q is not pressed
            while (isRunning)
            {
                WriteToConsole(ConsoleColor.Yellow, "MLS Marketing Menu [S + Return] para Sair : ");
                isRunning = HandleConsoleInput(service, Console.ReadLine());
            }

            // stop and shutdown
            service.OnStop();
            service.OnShutdown();
        }
Beispiel #7
0
 protected override void OnShutdown()
 {
     _implementer.OnShutdown();
 }