diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-04-24 20:40:34 -0400 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-04-24 20:40:34 -0400 |
| commit | e02b3f479ef9dbde00cd6ff18510526e3b54e73c (patch) | |
| tree | 4e551363508bd25e8b631fc2b230454f2ed0f164 /MediaBrowser.Server.Startup.Common/EntryPoints/KeepServerAwake.cs | |
| parent | f33b246501f493fcc8ef49e4ae3f9a1b47d804da (diff) | |
| parent | 6b1c6ace222d7b94a3a378b1a88126537349431d (diff) | |
Merge pull request #1681 from MediaBrowser/dev
Dev
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) |
