Example #1
0
 /// <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;
 }
Example #2
0
 /// <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;
 }
Example #3
0
 /// <summary>
 /// 停止服务
 /// </summary>
 /// <param name="hostControl"></param>
 /// <returns></returns>
 public bool Stop(Topshelf.HostControl hostControl)
 {
     this.Dispose();
     return true;
 }
Example #4
0
 /// <summary>
 /// Запускает службу
 /// </summary>
 /// <param name="hostControl"></param>
 /// <returns></returns>
 public bool Start(Topshelf.HostControl hostControl)
 {
     Stop(hostControl);
     Init(this.MicroServices, this.CancellationTokenSource.Token);
     return true;
 }