示例#1
0
 public bool Start(HostControl hostControl)
 {
     try
     {
         return(ServiceControl.Start(hostControl));
     }
     catch (Exception ex)
     {
         Logger.Fatal($"Unhandled exception occurred while starting the service: {ServiceName}", ex);
         throw;
     }
 }
示例#2
0
        void StartService(HostControl hostControl, ServiceControl service)
        {
            if (hostControl == null)
            {
                throw new ArgumentNullException(nameof(hostControl));
            }

            if (service == null)
            {
                return;
            }

            _log.InfoFormat("Starting Service {0}", service);

            if (!service.Start(hostControl))
            {
                throw new TopshelfException($"Failed to start service: {service}");
            }
        }
        void StartService(HostControl hostControl, ServiceControl service)
        {
            if (hostControl == null)
            {
                throw new ArgumentNullException("hostControl");
            }

            if (service == null)
            {
                return;
            }

            _log.InfoFormat("Starting Service {0}", service);

            if (!service.Start(hostControl))
            {
                throw new TopshelfException(string.Format((string)"Failed to start service: {0}", (object)service));
            }
        }
示例#4
0
 public void InitializeApplication()
 {
     try
     {
         Logger             = new WhiteDefaultLoggerFactory(TestLoggerLevel).Create(typeof(TestBase));
         Wait               = new Waiter();
         NameGenerator      = new NameGenerator();
         ServiceControlStub = ServiceControl.Start();
         Configuration      = new ProfilerConfiguration();
         Application        = Configuration.LaunchApplication();
         MainWindow         = Configuration.GetMainWindow(Application);
         Container          = CreateContainer();
         OnApplicationInitialized();
         OnSetupUI();
     }
     catch (Exception ex)
     {
         Logger.Error("Failed to launch application and get main window", ex);
         TryCloseApplication();
         throw;
     }
 }
示例#5
0
 public bool Start(HostControl hostControl)
 {
     return(_service.Start(hostControl));
 }
        void StartService(HostControl hostControl, ServiceControl service)
        {
            if (hostControl == null)
                throw new ArgumentNullException("hostControl");

            if (service == null)
                return;

            _log.InfoFormat("Starting Service {0}", service);

            if (!service.Start(hostControl))
                throw new TopshelfException(string.Format((string)"Failed to start service: {0}", (object)service));
        }
        void StartService(HostControl hostControl, ServiceControl service)
        {
            if (hostControl == null)
                throw new ArgumentNullException(nameof(hostControl));

            if (service == null)
                return;

            _log.InfoFormat("Starting Service {0}", service);

            if (!service.Start(hostControl))
                throw new TopshelfException($"Failed to start service: {service}");
        }
        /// <summary>
        /// 执行安装并启动服务
        /// </summary>
        /// <returns></returns>
        public static bool InstallService()
        {
            ServiceControl sc = new ServiceControl(ServiceName, ServiceExecutePath, ServiceDiscription);

            return(sc.Start());
        }