Usually you’re adviced to use something like that (using timeouts): Thread workerThread = null; AutoResetEvent finishedEvent = new AutoResetEvent(false); protected override void OnStart(string[] args) { this.finishedEvent.Reset(); this.workerThread = new Thread(this.Poll); this.workerThread.Start(); } protected override void OnStop() { this.finishedEvent.Set(); if(!this.workerThread.Join(2000)) { this.RequestAdditionalTime(5000); } } where Poll function is defined like: private void Poll() { try { […]
The post The common practice for polling inside Windows services appeared first on BlogoSfera.