private void OnSearchCompleted(object sender, SearchCompletedEventArgs e) { using (var conn = new SQLite.SQLiteConnection(mDatabasePath)) { conn.RunInTransaction(() => { var theWord = FindWord(conn, e.Word); // Did the user delete the word? if (theWord != null) { if (e.IsGeneralError) { theWord.Status = WordStatus.GENERAL_ERROR; } else if (e.IsNetworkError) { theWord.Status = WordStatus.NETWORK_ERROR; } else if (!e.Found || e.Waves.Count == 0) { theWord.Status = WordStatus.NOT_FOUND; } else { theWord.Status = WordStatus.COMPLETE; theWord.Pronunciation = e.Pronunciation; foreach (var wave in e.Waves) { conn.Insert(new WaveModel() { WordID = theWord.ID, WaveFileName = wave.Item2 }); } } conn.Update (theWord); } }); LoadNextWord (conn); RefreshWordsList (conn); } }
public void Search(string word) { lock (mSearchInProgressSync) { // Is there another search in progress? if (mWaitCallback != null) throw new Exception ("Search in progress"); mCurrentResult = new SearchCompletedEventArgs(word); mWaitCallback = new WaitCallback (SearchThread); ThreadPool.QueueUserWorkItem (mWaitCallback); } }