This is a migrated thread and some comments may be shown as answers.

SearchProvider with AutoResetEvent

1 Answer 26 Views
Map
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 15 Apr 2015, 07:43 AM

Dear All,

together with the address the Longitude & Latitude should be saved.

I tried to use the AutoResetEvent but it is not working.

After WaitOne() is called, nothing happens. The EventHanlder is never called.

Please let me know if you have an idea.

 

AutoResetEvent waitHandle = new AutoResetEvent(false); 

if (fullAddress != String.Empty && Item.Longitude == 0 && Item.Latitude == 0)
{
    Telerik.Windows.Controls.Map.BingSearchProvider provider = new Telerik.Windows.Controls.Map.BingSearchProvider(bingApplicationId);
    Telerik.Windows.Controls.Map.SearchRequest newSearchRequest = new Telerik.Windows.Controls.Map.SearchRequest();
    newSearchRequest.Query = fullAddress;


    EventHandler<Telerik.Windows.Controls.Map.SearchCompletedEventArgs> eventHandler = delegate(object sender, Telerik.Windows.Controls.Map.SearchCompletedEventArgs e) 
        {
            foreach (Telerik.Windows.Controls.Map.SearchResultSet result in e.Response.ResultSets)
            {
                if (result.SearchRegion != null)
                {
                    Item.Longitude = Convert.ToDecimal(result.SearchRegion.GeocodeLocation.BestView.Center.Longitude);
                    Item.Latitude = Convert.ToDecimal(result.SearchRegion.GeocodeLocation.BestView.Center.Latitude);
                    Debug.WriteLine(String.Format("{0} Latitude:{1} Longitude:{2}", Item.Name1, Item.Latitude, Item.Longitude));
                }
            }

            waitHandle.Set();
        };

    provider.SearchCompleted += eventHandler;

    provider.SearchAsync(newSearchRequest);
    waitHandle.WaitOne();

    Debug.WriteLine(fullAddress);
}

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 17 Apr 2015, 09:38 AM

Hello Manuel,

Unfortunately, the provided information is not enough to understand your current setup, requirement and the issues that you encounter.

Please elaborate more on your scenario. What you need to achieve? When are you trying to do it? What prevents you from implementing your requirement?

Please keep in mind that providing as detailed information as possible will help us to better handle your case.

Regards,
Pavel R. Pavlov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Map
Asked by
Manuel
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or