/// <summary> /// 重启托管服务 /// </summary> /// <returns> /// 托管服务状态响应 /// </returns> public ServiceStateResponse Restart() { ServiceStateResponse response = new ServiceStateResponse() { State = ServiceState.Unknown }; State = ServiceState.Restarting; response = Stop(); response = Start(); return(response); }
/// <summary> /// 停止托管服务 /// </summary> /// <returns> /// 托管服务状态响应 /// </returns> public ServiceStateResponse Stop() { ServiceStateResponse response = new ServiceStateResponse() { State = ServiceState.Unknown }; try { State = ServiceState.Stopping; OnStop(); State = ServiceState.Stopped; response.State = this.State; } catch (Exception ex) { State = ServiceState.StopFailed; response.State = this.State; response.StateMessage = ex.Message; ExceptionHandler.Handle(ex); } return(response); }