private void CheckAutoShutdown() { if (_autoShutdownMinutes != null && _totalStopwatch.Elapsed.TotalMinutes >= _autoShutdownMinutes) { _logger.Info(string.Format("GenericPoller {0} - Auto Shutdown at {1} Minutes", _className, _autoShutdownMinutes), "GenericPollerProcess", "CheckAutoShutdown"); System.Threading.Thread.Sleep(2000); //Logging happens async, sleep to make sure it completes before returning and shutting the app down this._continueExecution = false; } }