public void StartAsConsoleService() { Console.CancelKeyPress += (s, e) => { e.Cancel = true; _resetEvent.Set(); }; _daemon.Start(); _resetEvent.WaitOne(); _daemon.Stop(); }
protected override void OnStop() { base.OnStop(); OnEvent(Stopping, new WindowsServiceEventArgs(ServiceName)); try { _daemon.Stop(); } catch (Exception e) { OnEvent(Error, new ErrorEventArgs(new DaemonException(String.Format("Error stopping service '{0}'.", ServiceName), e))); throw; } OnEvent(Stopped, new WindowsServiceEventArgs(ServiceName)); }