private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) { AddressSearchDelegate asd = new AddressSearchDelegate(SearchAddresses); TextBox t = (sender as TextBox); asd.BeginInvoke(t.Text, new AsyncCallback(SearchFinishCallBack), asd); }
private void SearchFinishCallBack(IAsyncResult result) { AddressSearchDelegate asd = (AddressSearchDelegate)result.AsyncState; List <Address> currentAddresses = asd.EndInvoke(result); this.Dispatcher.Invoke((Action)(() => { //if (SearchResultsListBox == null) return; SearchedAddresses = currentAddresses; if (currentAddresses.Count == 1) { orderDetails.CurrentAddress = Helper.DeepClone <Address>(currentAddresses[0]); } })); }