Пример #1
0
        public void Run()
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            _osCommands.CheckToSeeIfServiceRunning(_description);

            try
            {
                _log.Debug("Starting up as a console application");

                _exit = new ManualResetEvent(false);

                Console.CancelKeyPress += HandleCancelKeyPress;

                _coordinator.Start();                 //user code starts

                _log.InfoFormat("[Topshelf] Running, press Control+C to exit.");

                _exit.WaitOne();
            }
            catch (Exception ex)
            {
                _log.Error("An exception occurred", ex);
            }
            finally
            {
                ShutdownCoordinator();
                _exit.Close();
            }
        }