Пример #1
0
        protected override void OnStart(string[] args)
        {
            Logger.Debug("Starting up the service...");

            /*
             * your service startup logic goes here. do not block, return imediately, start a task perhaps to
             * perform all the startup overhead.
             *
             * There are ways to request more time during on start or onstop, see the article in this project HowTo-Article.pdf
             */
            var task = new Task(() =>
            {
                try
                {
                    Thread.Sleep(10000);
                    throw new Exception("something went wrong...");
                }
                catch (Exception e)
                {
                    Logger.Error("This should trigger service Stop.", e);
                    this.StopService();
                }
            });

            task.Start();
        }
Пример #2
0
        private static void StartAsConsoleApp()
        {
            var service = new WindowsPlayService();

            service.StartService();

            Console.ReadKey(false);

            Logger.Debug("Stopping...");

            Thread.Sleep(1000);
        }