Exemple #1
0
        void StopService(HostControl hostControl, ServiceControl service)
        {
            if (hostControl == null)
            {
                throw new ArgumentNullException(nameof(hostControl));
            }

            if (service == null)
            {
                return;
            }

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

                if (!service.Stop(hostControl))
                {
                    throw new TopshelfException($"Failed to stop service: {service}");
                }
            }
            catch (Exception ex)
            {
                _log.Error("Stop Service Failed", ex);
            }
        }
Exemple #2
0
        public bool Stop(HostControl hostControl)
        {
            bool stop = _service.Stop(hostControl);

            if (stop)
            {
                _lifetimeScope.Dispose();
            }
            return(stop);
        }
Exemple #3
0
 public bool Stop(HostControl hostControl)
 {
     try
     {
         return(ServiceControl.Stop(hostControl));
     }
     catch (Exception ex)
     {
         // Log the error and force shutdown. Human intervention is needed at this point.
         Logger.Fatal($"Unhandled exception occurred while stopping the service: {ServiceName}", ex);
         return(true);
     }
 }
        void StopService(HostControl hostControl, ServiceControl service)
        {
            if (hostControl == null)
                throw new ArgumentNullException("hostControl");

            if (service == null)
                return;

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

                if (!service.Stop(hostControl))
                    throw new TopshelfException(string.Format((string)"Failed to stop service: {0}", (object)service));
            }
            catch (Exception ex)
            {
                _log.Error("Stop Service Failed", ex);
            }
        }
Exemple #5
0
 public void CleanUpTest()
 {
     ServiceControlStub.Stop();
     Container.Dispose();
     TryCloseApplication();
 }
        /// <summary>
        /// 执行卸载服务
        /// </summary>
        /// <returns></returns>
        public static bool UninstallService()
        {
            ServiceControl sc = new ServiceControl(ServiceName, ServiceExecutePath, ServiceDiscription);

            return(sc.Stop());
        }
 public bool Stop(HostControl hostControl)
 {
     return(_actualService.Stop(hostControl));
 }