DrillDownGeoCoderBeginGetStreets Method |
Namespace: Telogis.GeoBase
public IAsyncResult BeginGetStreets( string searchstring, AsyncCallback asyncCallback, Object asyncstate )
An asynchronous street search is performed using the drilldown geocoder's BeginGetStreets in conjunction with AbortGetStreets, and EndGetStreets. AbortGetStreets simply cancels an asynchronous street search operation; in the example below, it is used to cancel any previous search operation, so that we can safely start a new search.
BeginGetStreets will create a new thread and begin the search operation. When the search is complete, the callback function that is passed to BeginGetStreets is called. In the example below, the callback function (GetStreetsCallback(IAsyncResult searchResult)) calls UpdateStreetsList(), which in turn calls EndGetStreets to return the search results, once the search has completed, and populates the list box 'listBoxResults'.
This example assumes that the region levels, in the drill-down geocoder, have been set. It also assumes that we have a drilldown geocoder, called 'ddgc', and a list box to place the street search results in to, called 'listBoxResults'.
IAsyncResult asyncSearch; private void searchSteets(string filterText){ //Ensure previous asynchronous street search operation has stopped ddgc.AbortGetStreets(asyncSearch); //Begin the asynchronous search asyncSearch = ddgc.BeginGetStreets(filterText, getStreetsCallback, null); } private void getStreetsCallback(IAsyncResult searchResult) { updateStreetsList(); } private void updateStreetsList() { if (InvokeRequired) { Invoke(new MethodInvoker(UpdateStreetsList)); } else { StreetData[] sdlist = ddgc.EndGetStreets(asyncSearch).Results; listBoxResults.Items.AddRange(sdlist); } }