public void Run() { const string ServiceName = "EndeavourEmisWebPollerConsole"; _poller = new Poller(ServiceName, Stop); _poller.Start(); Log.WriteToConsoleAndLog(string.Empty); Log.WriteToConsoleAndLog(ServiceName + " service running. Press any key to stop service."); while (true) { if (_requestStop) { break; } if (Console.KeyAvailable) { while (Console.KeyAvailable) { Console.Read(); } Log.WriteToConsoleAndLog("Key pressed. Stopping service..."); break; } Thread.Sleep(200); } _poller.Stop(); Log.WriteToConsoleAndLog("Service stopped."); }
protected override void OnStop() { _poller.Stop(); base.OnStop(); }