/// <summary> /// 启动服务 /// </summary> /// <param name="hostControl"></param> /// <returns></returns> public bool Start(Topshelf.HostControl hostControl) { this.GlobalFilters.Add(new ExceptionFilter()); this.BindService<LnService>().BindService<SystemService>(); this.StartListen(int.Parse(ConfigurationManager.AppSettings["Port"])); return true; }
/// <summary> /// Останавливает службу /// </summary> /// <param name="hostControl"></param> /// <returns></returns> public bool Stop(Topshelf.HostControl hostControl) { if (_MicroServices.Count > 0) { _CancellationTokenSource.Cancel(); Task.WaitAll(_MicroServices.ToArray()); _MicroServices.Clear(); } return true; }
/// <summary> /// 停止服务 /// </summary> /// <param name="hostControl"></param> /// <returns></returns> public bool Stop(Topshelf.HostControl hostControl) { this.Dispose(); return true; }
/// <summary> /// Запускает службу /// </summary> /// <param name="hostControl"></param> /// <returns></returns> public bool Start(Topshelf.HostControl hostControl) { Stop(hostControl); Init(this.MicroServices, this.CancellationTokenSource.Token); return true; }