/// <summary> /// OnStop(): Put your stop code here /// - Stop threads, set final data, etc. /// </summary> protected override void OnStop() { try { _log.Info("Stoping service\r\n"); if (_cancelTokenSource != null) { _cancelTokenSource.Cancel(); } if (_queueManager != null) { _queueManager.CancelHandler.WaitOne(); } StopTimer(); if (_workTimer != null) { _workTimer.Dispose(); _workTimer = null; } if (_queueManager != null) { _queueManager.Dispose(); } if (_signalrWorker != null) { _signalrWorker.Dispose(); } } catch (Exception ex) { _log.ErrorFormat("Stop service Error: {0}\r\n", ex.ToString()); } finally { _log.Info("Stop service\r\n"); base.OnStop(); if (_resetEvent != null) { _resetEvent.Set(); } if (_healthCheckServiceHost != null) { _healthCheckServiceHost.Close(); _healthCheckServiceHost = null; } } }
/// <summary> /// OnStop(): Put your stop code here /// - Stop threads, set final data, etc. /// </summary> protected override void OnStop() { _cancelTokenSource.Cancel(); _log.Info("Stop service\r\n"); _queueManager.CancelHandler.WaitOne(); StopTimer(); if (_workTimer != null) { _workTimer.Dispose(); _workTimer = null; } _resetEvent.Set(); _queueManager.Dispose(); _signalrWorker.Dispose(); base.OnStop(); }