示例#1
0
        /// <summary>
        /// 重启托管服务
        /// </summary>
        /// <returns>
        /// 托管服务状态响应
        /// </returns>
        public ServiceStateResponse Restart()
        {
            ServiceStateResponse response = new ServiceStateResponse() { State = ServiceState.Unknown };

              State = ServiceState.Restarting;
              response = Stop();
              response = Start();

              return response;
        }
示例#2
0
        /// <summary>
        /// 启动托管服务
        /// </summary>
        /// <returns>
        /// 托管服务状态响应
        /// </returns>
        public ServiceStateResponse Start()
        {
            ServiceStateResponse response = new ServiceStateResponse() { State = ServiceState.Unknown };

              try
              {
            State = ServiceState.Starting;
            OnStart();
            State = ServiceState.Started;
            response.State = this.State;
              }
              catch (Exception ex)
              {
            State = ServiceState.StartFailed;
            response.State = this.State;
            response.StateMessage = ex.Message;
            ExceptionHandler.Handle(ex);
              }

              return response;
        }