private void CallbackFindSuggestions(IAsyncResult iAsyncResult) { AsyncResult asyncResult = iAsyncResult as AsyncResult; FindSuggestionAsync.FindSuggestionAsyncDelegate caller = asyncResult.AsyncDelegate as FindSuggestionAsync.FindSuggestionAsyncDelegate; caller.EndInvoke(iAsyncResult); List <string> collection = russianWordsSuggestionService.Suggestions; List <SuggestionBusinessObject> suggestions = new List <SuggestionBusinessObject> { FirstSuggestion, SecondSuggestion, ThirdSuggestion }; if (!collection.Any()) { return; } int tmp = 3; if (collection.Count < 3) { tmp = collection.Count; } for (int i = 0; i < tmp; ++i) { suggestions[i].Word = collection[i]; } }
private void AsyncFindSuggestions() { if (Value != 100) { MessageBox.Show("Wait for the dictionary to load."); return; } FindSuggestionAsync.FindSuggestionAsyncDelegate findSuggestion = russianWordsSuggestionService.Find; try { asyncFindSuggestions = findSuggestion.BeginInvoke(StringOperation.LastWord(Buffer), Consts.CountSuggestions, CallbackFindSuggestions, null); } catch (ArgumentException) { // This block must be empty. } }