From: <Sil...@us...> - 2010-03-01 22:20:05
|
Revision: 3476 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3476&view=rev Author: SilentException Date: 2010-03-01 22:19:49 +0000 (Mon, 01 Mar 2010) Log Message: ----------- * reset the manualresetevent before starting new threads so they don't end instantly * kill background workers before starting new ones Modified Paths: -------------- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/FindLyric.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/FindLyric.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/FindLyric.cs 2010-03-01 20:06:50 UTC (rev 3475) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/FindLyric.cs 2010-03-01 22:19:49 UTC (rev 3476) @@ -216,7 +216,8 @@ } // If automaticUpdate is set then return after the first positive search - lc = new LyricsController(this, m_EventStopThread, (string[]) sitesToSearch.ToArray(), true, automaticUpdate, + m_EventStopThread = new ManualResetEvent(false); + lc = new LyricsController(this, m_EventStopThread, (string[])sitesToSearch.ToArray(), true, automaticUpdate, m_find, m_replace); ThreadStart job = delegate { lc.Run(); }; Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs 2010-03-01 20:06:50 UTC (rev 3475) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs 2010-03-01 22:19:49 UTC (rev 3476) @@ -845,6 +845,7 @@ m_replace = xmlreader.GetValueAsString("myLyrics", "replace", ""); } + m_EventStopThread = new ManualResetEvent(false); lc = new LyricsController(this, m_EventStopThread, sitesToSearchArray, false, false, m_find, m_replace); lc.NoOfLyricsToSearch = lyricConfigInfosQueue.Count; Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2010-03-01 20:06:50 UTC (rev 3475) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2010-03-01 22:19:49 UTC (rev 3476) @@ -1041,6 +1041,8 @@ if (_CurrentTrackTag != null) { + if (worker.IsBusy) + worker.CancelAsync(); SaveLyricToTagListsData data = new SaveLyricToTagListsData(_LyricText, _artist, _title, _CurrentTrackTag.FileName); worker.RunWorkerAsync(data); //SaveLyricToTagLists(_CurrentTrackTag.FileName, _LyricText); @@ -1401,7 +1403,7 @@ { _lyricsFound = false; - _lc = new LyricsController(this, _EventStopThread, new string[1] {"LrcFinder"}, false, false, + _lc = new LyricsController(this, _EventStopThread, new string[1] { "LrcFinder" }, false, false, _Find, _Replace); // create worker thread instance @@ -1440,6 +1442,8 @@ private bool FindLyric() { + _EventStopThread.Reset(); + if ((_CurrentTrackTag != null && _CurrentTrackTag.Artist != "") || g_Player.IsRadio) { if (_enableLogging) @@ -1688,6 +1692,8 @@ if (_CurrentTrackTag != null) { + if (worker.IsBusy) + worker.CancelAsync(); SaveLyricToTagListsData data = new SaveLyricToTagListsData(_LyricText, artist, title, _CurrentTrackTag.FileName); worker.RunWorkerAsync(data); //SaveLyricToTagLists(_CurrentTrackTag.FileName, _LyricText); @@ -1979,7 +1985,7 @@ _LyricText = MediaPortalUtil.MakePlainLyricPerfectToShow(_LyricText); - resetGUI((int) MyLyricsSettings.Screen.LYRICS); + resetGUI((int)MyLyricsSettings.Screen.LYRICS); GUIControl.SetControlLabel(GetID, CONTROL_LYRIC_SELECTED, _LyricText); GUIControl.FocusControl(GetID, CONTROL_LYRIC_SELECTED); } @@ -2042,7 +2048,6 @@ // set event "Stop" _EventStopThread.Set(); - while (_LyricControllerThread.IsAlive) Thread.Sleep(100); @@ -2337,6 +2342,8 @@ if (_CurrentTrackTag != null) { + if (worker.IsBusy) + worker.CancelAsync(); SaveLyricToTagListsData data = new SaveLyricToTagListsData(lyricText, _artist, _title, _CurrentTrackTag.FileName); worker.RunWorkerAsync(data); //SaveLyricToTagLists(_CurrentTrackTag.FileName, lyricText); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |