protected override void OnStop() { KeepRunning = false; if (_InfoClient != null) { _InfoClient.Stop(); _InfoClient = null; } }
protected override void OnStart(string[] args) { KeepRunning = true; System.Threading.Tasks.Task.Factory.StartNew(() => { while (KeepRunning) { if (_InfoClient == null || !_InfoClient.Connected) { _InfoClient = new WindowsService.InfoClient("192.168.0.2", 4500, 5000); _InfoClient.Start(); } System.Threading.Thread.Sleep(1000 * 5);// one minute reconnect interval } }); }