Passing user data in a BingRest request

2 posts, 0 answers
  1. Ken
    Ken avatar
    13 posts
    Member since:
    Apr 2018

    Posted 06 Jan Link to this post

    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?

  2. Ken
    Ken avatar
    13 posts
    Member since:
    Apr 2018

    Posted 06 Jan in reply to Ken Link to this post

    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.
Back to Top