Пример #1
0
        /// <summary>
        /// Creates or removes <see cref="IIntervalWork"/> from <see cref="IThreadPool"/>.
        /// </summary>
        /// <param name="psc">IPlayerSlotController</param>
        /// <param name="starting"><c>true</c> if starting, <c>false</c> if stopping.</param>
        /// <returns><c>true</c> if work should be removed when done.</returns>
        private bool HandleTasks(IPlayerSlotController psc, bool starting)
        {
            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();

            lock (_syncObj)
            {
                // On stop, abort background interval work
                if (!starting && _progressUpdateWorks.ContainsKey(psc))
                {
                    threadPool.RemoveIntervalWork(_progressUpdateWorks[psc].Work);
                    return(true);
                }

                // When starting, create an asynchronous work and exit here
                if (!_progressUpdateWorks.ContainsKey(psc))
                {
                    IntervalWork work = new IntervalWork(() => HandleScrobble(psc, true), UPDATE_INTERVAL);
                    threadPool.AddIntervalWork(work, false);
                    _progressUpdateWorks[psc] = new PositionWatcher {
                        Work = work
                    };
                }
            }
            return(false);
        }
Пример #2
0
        public ResourceAccessModule(OwinMiddleware next) : base(next)
        {
            AddDefaultMimeTypes();
            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();

            _tidyUpCacheWork = new IntervalWork(TidyUpResourceAccessorCache, CACHE_CLEANUP_INTERVAL);
            threadPool.AddIntervalWork(_tidyUpCacheWork, false);
        }
        public void Startup()
        {
            if (_checkTimeoutIntervalWork != null)
            {
                return;
            }
            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();

            _checkTimeoutIntervalWork = new IntervalWork(CheckTimeouts, TIMESPAN_CHECK_NOTIFICATION_TIMEOUTS);
            threadPool.AddIntervalWork(_checkTimeoutIntervalWork, true);
        }
        public TranscodingServicePlugin()
        {
            _profileManager = new TranscodeProfileManager();
            ServiceRegistration.Set <ITranscodeProfileManager>(_profileManager);
            Logger.Debug("TranscodingService: Registered TranscodeProfileManager.");

            _analysisLibraryManager = new AnalysisLibraryManager();

            _settings = new SettingsChangeWatcher <TranscodingServiceSettings>();
            _settings.SettingsChanged = OnSettingsChanged;
            _settings.Refresh();

            _tidyUpCacheWork = new IntervalWork(TidyUpCache, CACHE_CLEANUP_INTERVAL);
            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();

            threadPool.AddIntervalWork(_tidyUpCacheWork, false);
        }