public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            ThreadAssist.ProxyToMain(delegate {
                lock (initiated_lock) {
                    initiated = false;
                    instanceCount--;
                    if (instanceCount < 1)
                    {
                        weightedRandom = null;
                    }
                }
                disposed = true;
            });
        }
        public RandomByLastfmUserTopArtists() : base("lastfm_shuffle_topartists")
        {
            Label       = AddinManager.CurrentLocalizer.GetString("Shuffle by your Top Artists (via Lastfm)");
            Adverb      = AddinManager.CurrentLocalizer.GetString("by your top artists");
            Description = AddinManager.CurrentLocalizer.GetString("Play songs from your Top Artists (via Lastfm)");

            Condition = "CoreArtists.ArtistID = ?";
            OrderBy   = "RANDOM()";

            lock (initiated_lock) {
                instanceCount++;
                if (!initiated)
                {
                    ServiceManager.PlayerEngine.ConnectEvent(RandomByLastfmUserTopArtists.OnPlayerEvent, PlayerEvent.StateChange);
                    initiated = true;
                    Log.Debug("RandomByLastfmUserTopArtists: Initialising List");
                    weightedRandom = new WeightedRandom <int> ();
                }
            }
        }
        public RandomByLastfmSimilarArtists() : base("lastfm_shuffle_similar_artists")
        {
            Label       = AddinManager.CurrentLocalizer.GetString("Shuffle by similar Artists (via Lastfm)");
            Adverb      = AddinManager.CurrentLocalizer.GetString("by similar artists");
            Description = AddinManager.CurrentLocalizer.GetString("Play songs similar to those already played (via Lastfm)");

            lock (initiated_lock) {
                instanceCount++;
                if (!initiated)
                {
                    ServiceManager.PlayerEngine.ConnectEvent(RandomByLastfmSimilarArtists.OnPlayerEvent, PlayerEvent.StateChange);
                    initiated        = true;
                    weightedRandom   = new WeightedRandom <long> ();
                    processedArtists = new List <long> ();
                }
            }

            Condition = "CoreArtists.ArtistID = ?";
            OrderBy   = "RANDOM()";
        }
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            ThreadAssist.ProxyToMain(delegate {
                ServiceManager.PlayerEngine.DisconnectEvent(RandomByLastfmSimilarArtists.OnPlayerEvent);
                lock (initiated_lock) {
                    initiated = false;
                    instanceCount--;
                    if (instanceCount < 1)
                    {
                        weightedRandom   = null;
                        processedArtists = null;
                    }
                }
                disposed = true;
            });
        }