public void Stop() { StopHealthCheckMonitor(); this._cancellationTokenSource.Cancel(); this._cancellationTokenSource.Dispose(); WaitHandle handle = new AutoResetEvent(false); _producerTimer.Dispose(handle); _consumerTask.Wait(); handle.WaitOne(); _ruleServiceInstanceFactory().MakeInactiveRuleInstance(); _metricsCollector.Stop(); }