Ejemplo n.º 1
0
 private void ItemCompleted(MediaItem nextItem)
 {
     Log.Logger.Debug($"Done item {nextItem.FilePath}");
     ItemCompletedEvent?.Invoke(this, new ItemMetaDataPopulatedEventArgs {
         MediaItem = nextItem
     });
 }
Ejemplo n.º 2
0
        private void RunConsumerTask()
        {
            try
            {
                while (!_cancellationToken.IsCancellationRequested)
                {
                    var nextItem = _collection.Take(_cancellationToken);

                    Log.Logger.Debug($"Consuming item {nextItem.FilePath}");

                    if (!IsPopulated(nextItem))
                    {
                        PopulateThumbnailAndMetaData(nextItem);

                        if (!IsPopulated(nextItem))
                        {
                            // put it back in the queue!
                            ReplaceInQueue(nextItem);
                        }
                        else
                        {
                            Log.Logger.Debug($"Done item {nextItem.FilePath}");
                            ItemCompletedEvent?.Invoke(this, new ItemMetaDataPopulatedEventArgs {
                                MediaItem = nextItem
                            });
                        }

                        Log.Logger.Verbose("Metadata queue size (consumer) = {QueueSize}", _collection.Count);

                        if (_collection.Count == 0)
                        {
                            AllItemsCompletedEvent?.Invoke(this, EventArgs.Empty);
                        }
                    }
                }
            }
            catch (OperationCanceledException)
            {
                Log.Logger.Debug("Metadata consumer closed");
            }
        }