protected override void Execute() { try { if (text.Length > 0) { foreach (GPLocation loc in GPLocationList.getShared().locations) { if (loc.getCity().IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0) { Locations.Add(loc); } if (Cancelled) { break; } } Valid = !Cancelled; } } catch { Valid = false; } }
private void StartForm_FormClosing(object sender, FormClosingEventArgs e) { GPStrings.getSharedStrings().Save(); GPLocationList.getShared().Save(); GPEventList.getShared().Save(); GPCountryList.getShared().Save(); GPTimeZoneList.sharedTimeZones().Save(); GPLocationProvider.SaveRecent(); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { while (true) { if (findTextChanged == false) { System.Threading.Thread.Sleep(1000); } else { List <GPLocation> locs = new List <GPLocation>(); bool interrupted = false; bool finished = false; string text; while (!finished) { lock (findText) { text = findText; } listView1.Invoke(new ClearLocationListDelegate(ClearLocationList)); interrupted = false; findTextChanged = false; if (text.Length > 0) { foreach (GPLocation loc in GPLocationList.getShared().locations) { if (loc.getCity().IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0) { locs.Add(loc); } if (findTextChanged) { interrupted = true; break; } } } if (!interrupted) { finished = true; } } listView1.Invoke(new AddLocationToViewDelegate(AddLocationToView), locs); listView1.Invoke(new SetSelectionDelegate(SetSelection)); } } }