コード例 #1
0
ファイル: CommandSet.cs プロジェクト: SteffenBlake/synoptic
 public void StartAsConsoleService()
 {
     Console.CancelKeyPress += (s, e) => { e.Cancel = true; _resetEvent.Set(); };
     _daemon.Start();
     _resetEvent.WaitOne();
     _daemon.Stop();
 }
コード例 #2
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            OnEvent(Starting, new WindowsServiceEventArgs(ServiceName));

            try
            {
                _daemon.Start();
            }
            catch (Exception e)
            {
                OnEvent(Error, new ErrorEventArgs(new DaemonException(String.Format("Error starting service '{0}'.", ServiceName), e)));
                throw;
            }

            OnEvent(Started, new WindowsServiceEventArgs(ServiceName));
        }