diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-04-23 14:38:36 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-04-23 14:38:36 -0400 |
| commit | 9807448fce0bba3b1aaf9fcb249efc5efe7b3146 (patch) | |
| tree | 51ab4c888b1572150301fa383e6ccf97f9e88fec /MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs | |
| parent | 85a9363c7806be6206c6e6f4a533d7ed578c3787 (diff) | |
update sleep prevention
Diffstat (limited to 'MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs')
| -rw-r--r-- | MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs b/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs index 20d4c6b2a..dbfd6f4e8 100644 --- a/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs +++ b/MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs @@ -27,28 +27,27 @@ namespace MediaBrowser.Server.Startup.Common.EntryPoints _timer = new PeriodicTimer(obj => { var now = DateTime.UtcNow; - if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15)) + var nativeApp = ((ApplicationHost)_appHost).NativeApp; + + try + { + if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15)) + { + nativeApp.PreventSystemStandby(); + } + else + { + nativeApp.AllowSystemStandby(); + } + } + catch (Exception ex) { - KeepAlive(); + _logger.ErrorException("Error resetting system standby timer", ex); } }, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); } - private void KeepAlive() - { - var nativeApp = ((ApplicationHost)_appHost).NativeApp; - - try - { - nativeApp.PreventSystemStandby(); - } - catch (Exception ex) - { - _logger.ErrorException("Error resetting system standby timer", ex); - } - } - public void Dispose() { if (_timer != null) |
