Exemplo n.º 1
0
        private bool PumpQueue(ArrayList queue,
                               SinglePodcastAction spa, MultiplePodcastAction mpa)
        {
            PodcastInfo pi       = null;
            ICollection podcasts = null;

            int range_upper = -1;

            lock (queue.SyncRoot)
            {
                if (queue.Count == 0)
                {
                    return(false);
                }

                int queue_count = queue.Count;
                // A count of 32 caused relatively skipless audio playback
                // while synchronizing large feeds (200-300 episodes).
                range_upper = (queue_count >= 32) ? 31 : queue_count;

                if (queue_count == 1)
                {
                    pi = queue [0] as PodcastInfo;
                }
                else if (queue_count > 1)
                {
                    podcasts = queue.GetRange(0, range_upper);
                }
            }

            if (pi != null)
            {
                spa(pi);
            }
            else if (podcasts != null)
            {
                mpa(podcasts);
            }

            lock (queue.SyncRoot)
            {
                queue.RemoveRange(0, range_upper);

                if (queue.Count == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
        private bool PumpQueue(ArrayList queue,
                                SinglePodcastAction spa, MultiplePodcastAction mpa)
        {
            PodcastInfo pi = null;
            ICollection podcasts = null;

            int range_upper = -1;

            lock (queue.SyncRoot)
            {

                if (queue.Count == 0)
                {
                    return false;
                }

                int queue_count = queue.Count;
            // A count of 32 caused relatively skipless audio playback
            // while synchronizing large feeds (200-300 episodes).
                range_upper = (queue_count >= 32) ? 31 : queue_count;

                if (queue_count == 1)
                {
                    pi = queue [0] as PodcastInfo;
                }
                else if (queue_count > 1)
                {
                    podcasts = queue.GetRange (0, range_upper);
                }
            }

            if (pi != null)
            {
                spa (pi);
            }
            else if (podcasts != null)
            {
                mpa (podcasts);
            }

            lock (queue.SyncRoot)
            {
                queue.RemoveRange (0, range_upper);

                if (queue.Count == 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }