示例#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);
        }
示例#2
0
        public static void Run(string[] args, IWindowsService service)
        {
            string serviceName = service.GetType().Name;
            bool isRunning = true;
            service.OnStart(args);

            while (isRunning){
                WriteToConsole(ConsoleColor.Yellow, "Enter either [Q]uit, [P]ause, [R]esume : ");
                isRunning = HandleConsoleInput(service, Console.ReadLine());
            }
            // stop
            service.OnStop();
        }
示例#3
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();
        }
示例#5
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();
        }
示例#6
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();
        }
示例#8
0
        /// <summary>
        /// Run a given <see cref="IWindowsService"/> using the console harness.
        /// </summary>
        /// <param name="args">Arguments to pass to the service <see cref="IWindowsService.OnStart"/> method.</param>
        /// <param name="service">The service to run.</param>
        public static void Run(String[] args, IWindowsService service)
        {
            ServiceState state = ServiceState.Running;

            using (service)
            {
                service.OnStart(args);

                while (state != ServiceState.Stopped)
                {
                    Console.WriteLine("[muster] Currently {0}: [Q]uit [P]ause [R]esume", state);

                    while (!Console.KeyAvailable)
                        Thread.Sleep(250);

                    TryHandleConsoleInput(service, Console.ReadKey(true).Key, ref state);
                }

                service.OnStop();
            }
        }
示例#9
0
 // because all of these available overrides are protected, we can't
 // call them directly from our console harness, so instead we will
 // just delegate to the IWindowsService interface which is public.
 protected override void OnStart(string[] args)
 {
     _implementer.OnStart(args);
 }