using MediaBrowser.Common.Security; using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Logging; using System; using System.Threading.Tasks; using MediaBrowser.Controller.Threading; namespace MediaBrowser.Server.Implementations.EntryPoints { /// /// Class LoadRegistrations /// public class LoadRegistrations : IServerEntryPoint { /// /// The _security manager /// private readonly ISecurityManager _securityManager; /// /// The _logger /// private readonly ILogger _logger; private PeriodicTimer _timer; /// /// Initializes a new instance of the class. /// /// The security manager. /// The log manager. public LoadRegistrations(ISecurityManager securityManager, ILogManager logManager) { _securityManager = securityManager; _logger = logManager.GetLogger("Registration Loader"); } /// /// Runs this instance. /// public void Run() { _timer = new PeriodicTimer(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); } } /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { if (_timer != null) { _timer.Dispose(); _timer = null; } } } }