diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-11-03 19:59:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-03 19:59:50 -0400 |
| commit | c53745548ac2130f4cfbbe0d7a2804c36c8ae4eb (patch) | |
| tree | 6ee298ebb5470c4f3bcbef8d814a0354901469c4 /Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs | |
| parent | 338b04a0c58729ec70aed89924ea6bd12422872b (diff) | |
| parent | 405a5f69c5967b4d919b5fe91396f12cb83e8aa8 (diff) | |
Merge pull request #2267 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs')
| -rw-r--r-- | Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs b/Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs new file mode 100644 index 0000000000..0203b51928 --- /dev/null +++ b/Emby.Server.Implementations/EntryPoints/LoadRegistrations.cs @@ -0,0 +1,73 @@ +using MediaBrowser.Common.Security; +using MediaBrowser.Controller.Plugins; +using MediaBrowser.Model.Logging; +using System; +using System.Threading.Tasks; +using MediaBrowser.Model.Threading; + +namespace Emby.Server.Implementations.EntryPoints +{ + /// <summary> + /// Class LoadRegistrations + /// </summary> + public class LoadRegistrations : IServerEntryPoint + { + /// <summary> + /// The _security manager + /// </summary> + private readonly ISecurityManager _securityManager; + + /// <summary> + /// The _logger + /// </summary> + private readonly ILogger _logger; + + private ITimer _timer; + private readonly ITimerFactory _timerFactory; + + /// <summary> + /// Initializes a new instance of the <see cref="LoadRegistrations" /> class. + /// </summary> + /// <param name="securityManager">The security manager.</param> + /// <param name="logManager">The log manager.</param> + public LoadRegistrations(ISecurityManager securityManager, ILogManager logManager, ITimerFactory timerFactory) + { + _securityManager = securityManager; + _timerFactory = timerFactory; + + _logger = logManager.GetLogger("Registration Loader"); + } + + /// <summary> + /// Runs this instance. + /// </summary> + public void Run() + { + _timer = _timerFactory.Create(s => LoadAllRegistrations(), null, TimeSpan.FromMilliseconds(100), TimeSpan.FromHours(12)); + } + + private async Task LoadAllRegistrations() + { + try + { + await _securityManager.LoadAllRegistrationInfo().ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error loading registration info", ex); + } + } + + /// <summary> + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// </summary> + public void Dispose() + { + if (_timer != null) + { + _timer.Dispose(); + _timer = null; + } + } + } +} |
