How to hold loop progress until an event completes?
i'm trying loop through text in textbox word in order spellcheck it. i've split contents of textbox array, , loop through each word in array , run through spellchecker. when misspelling found, have popup listbox inside display can choose correction.
issue i'm having, loops through whole array , ends showing last correction needs done.
how pause loop waits selection made , resume?
here's code loop:
foreach(string checkedword in articlewords)
{
bool success = _spellchecker.checkword(checkedword);
list<string> suggest;
if (!success)
{
suggest = _spellchecker.getsuggestions(checkedword);
spellchecklistbox.items.clear();
foreach (string s in suggest)
{
spellchecklistbox.items.add(new listboxitem() { content = s });
}
spellcheckerpopup.isopen = true;
spellchecklistbox.items.add(new listboxitem() { content = " ----------------------" });
spellchecklistbox.items.add(new listboxitem() { content = "ignore" });
}
}
when spellcheckerpopup displays, have event trigger in listbox on selectionchange.
basically, need pause loop somehow, , when selectionchange event it's thing, have loop resume.
in advance!
-sootah
// set value articlewords here queue<string> articlewords; private void dowork() { if (articlewords.count() > 0) { string checkedwork = articlewords.dequeue(); bool success = _spellchecker.checkword(checkedword); list<string> suggest; if (!success) { suggest = _spellchecker.getsuggestions(checkedword); spellchecklistbox.items.clear(); foreach (string s in suggest) { spellchecklistbox.items.add(new listboxitem() { content = s }); } spellcheckerpopup.isopen = true; spellchecklistbox.items.add(new listboxitem() { content = " ----------------------" }); spellchecklistbox.items.add(new listboxitem() { content = "ignore" }); } } } private void listbox1_selectionchanged(object sender, selectionchangedeventargs e) { dowork(); }
hope helps!
Silverlight > Programming Silverlight with .NET – General
Comments
Post a Comment