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

Passing user data in a BingRest request

1 Answer 54 Views
Map
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 06 Jan 2020, 10:14 PM

In the Search Location article, I've successfully tried out both Examples 2 and 3.  Each of them use SearchLocationAsync to make the request and restProvider_SearchLocationCompleted to handle the return.  In my app, I'd like to provide the user with the ability to search by address or location, and to do other things, too, but it looks like there can be only one implementation of restProvider_SearchLocationCompleted.  Of course, each request will need its own handling of the return, so how is that best accomplished?

I noticed that BingRestSearchLocationCompletedEventArgs has a UserData property that's an Object, so I assume the caller can create an object of their own design, populate it as desired and have it returned through this property.  If so, I could include an enum which my handler could use to determine how to process the return, which would solve my need.

The problem I'm having, though, is that I don't know how to send that UserData object along with my request.  There doesn't seem to be a parameter in the BingRestSearchLocation method that would allow me to.

So, I have two questions:

1. Is what I'm suggesting the normal way of handling this?  If not, what is normally done?

2. How does one send UserData in the request, so that it comes through in the completion handler?

1 Answer, 1 is accepted

Sort by
0
Ken
Top achievements
Rank 1
answered on 07 Jan 2020, 04:58 AM
Never mind.  I found the answer.  BingRestSearchLocationRequest.UserData allows the caller to provide the UserData object.  I did not find this property earlier, because it doesn't show up in the API for the BingRestSearchLocationRequest class, but it does in the class' base class, BaseRequest.
Tags
Map
Asked by
Ken
Top achievements
Rank 1
Answers by
Ken
Top achievements
Rank 1
Share this question
or