internal LyricSearch(LyricsController lyricsController, string artist, string title, string strippedArtistName, int row, bool allowAllToComplete, bool automaticUpdate) { _mLyricsController = lyricsController; _mArtist = strippedArtistName; _mTitle = title; _mRow = row; _mOriginalArtist = artist; _mOriginalTrack = title; _mAllowAllToComplete = allowAllToComplete; _mAutomaticUpdate = automaticUpdate; _mEventStopSiteSearches = new ManualResetEvent(false); _timer = new Timer(); _timer.Enabled = true; _timer.Interval = TimeLimit; _timer.Elapsed += StopDueToTimeLimit; _timer.Start(); }
internal LyricSearch(LyricsController lc, string artist, string title, string strippedArtistName, int row, bool allowAllToComplete, bool automaticUpdate) { m_lc = lc; m_artist = strippedArtistName; m_title = title; m_row = row; m_originalArtist = artist; m_originalTrack = title; m_allowAllToComplete = allowAllToComplete; m_automaticUpdate = automaticUpdate; m_EventStop_SiteSearches = new ManualResetEvent(false); timer = new System.Timers.Timer(); timer.Enabled = true; timer.Interval = TIME_LIMIT; timer.Elapsed += new System.Timers.ElapsedEventHandler(StopDueToTimeLimit); timer.Start(); }
private void stopSearch() { Monitor.Enter(this); try { if (lc != null) { lc.FinishThread(originalArtist, originalTitle, "", ""); lc.Dispose(); lc = null; } else { m_EventStopThread.Set(); ThreadFinishedMethod(originalArtist, originalTitle, "", ""); } m_LyricControllerThread = null; } finally { Monitor.Exit(this); } }
private void fetchLyric(string artist, string title, bool automaticUpdate) { log.Trace(">>>"); lockGUI(); tbLyrics.Text = ""; lvSearchResults.Items.Clear(); counter = 0; sitesToSearch = new List<string>(); if (Options.MainSettings.SearchLyricWiki) sitesToSearch.Add("LyricWiki"); if (Options.MainSettings.SearchHotLyrics) sitesToSearch.Add("HotLyrics"); if (Options.MainSettings.SearchLyrics007) sitesToSearch.Add("Lyrics007"); if (Options.MainSettings.SearchLyricsOnDemand) sitesToSearch.Add("LyricsOnDemand"); if (Options.MainSettings.SearchLyricsPlugin) sitesToSearch.Add("LyricsPluginSite"); // If automaticUpdate is set then return after the first positive search lc = new LyricsController(this, m_EventStopThread, sitesToSearch.ToArray(), true, automaticUpdate, "", ""); ThreadStart job = delegate { lc.Run(); }; m_LyricControllerThread = new Thread(job); m_LyricControllerThread.Name = "lyricSearch Thread"; // looks nice in Output window m_LyricControllerThread.Start(); lc.AddNewLyricSearch(artist, title, GetStrippedPrefixArtist(artist, m_strippedPrefixStrings)); log.Trace("<<<"); }
private void bgWorkerLyrics_DoWork(object sender, DoWorkEventArgs e) { if (lyricsQueue.Count > 0) { // start running the lyricController lc = new LyricsController(this, m_EventStopThread, sitesToSearch.ToArray(), false, false, "", ""); lc.NoOfLyricsToSearch = lyricsQueue.Count; ThreadStart runLyricController = delegate { lc.Run(); }; m_LyricControllerThread = new Thread(runLyricController); m_LyricControllerThread.Start(); lc.StopSearches = false; int row = 0; while (lyricsQueue.Count != 0) { if (lc == null) return; if (lc.NoOfCurrentSearches < m_NoOfCurrentSearchesAllowed && lc.StopSearches == false) { string[] lyricID = (string[])lyricsQueue.Dequeue(); if (Options.MainSettings.SwitchArtist) lyricID[0] = SwitchArtist(lyricID[0]); lc.AddNewLyricSearch(lyricID[0], lyricID[1], GetStrippedPrefixArtist(lyricID[0], m_strippedPrefixStrings), row); row++; } Thread.Sleep(100); } } else { ThreadFinished = new[] {"", "", localisation.ToString("lyricssearch", "NothingToSearch"), ""}; } }