none
Await Callback

    Question

  • I'm trying to use an Async method from the Nokia Music API.

    The document states..

    The SearchAsync method

    The <samp class="ph codeph">SearchAsync</samp> method allows you to search for artists and products.

    Table 2. Search Parameters
    Name Description
    <samp class="ph codeph">callback</samp> The delegate to call once a response has been received.
    <samp class="ph codeph">searchTerm</samp> Free-text search filter - this can be an artist or track name or other keywords such as "love".
    <samp class="ph codeph">category</samp> Optional category of item to get.

    But when I start typing SearchAsync, I see no callback placeholder in the intellisense window.  Should it be there as a parameter ?

    Tuesday, September 02, 2014 8:53 AM

Answers

  • I haven't used that API, but it looks like if you call SearchAsync it returns the value as a task. You can await it and not deal with an explicit callback. Alternatively, you can call Search (non-Async) and pass a callback as the first argument.

    --Rob

    Wednesday, September 03, 2014 7:59 AM
    Moderator

All replies

  • Which class are you calling this on?

    SearchAsync should take a parameter. Depending on how it's defined it's possible that Intellisense isn't picking it up. What does the Object Browser show? Do you get a compilation error when you pass a parameter as shown in the docs?

    --Rob

    Tuesday, September 02, 2014 7:21 PM
    Moderator
  • Public Function SearchAsync(Optional searchTerm As String = Nothing, Optional category As Nokia.Music.Types.Category? = Nothing, Optional genreId As String = Nothing, Optional orderBy As Nokia.Music.Types.OrderBy? = Nothing, Optional sortOrder As Nokia.Music.Types.SortOrder? = Nothing, Optional startIndex As Integer = 0, Optional itemsPerPage As Integer = 10, Optional requestId As System.Guid? = Nothing, Optional cancellationToken As System.Threading.CancellationToken? = Nothing) As System.Threading.Tasks.Task(Of Nokia.Music.ListResponse(Of Nokia.Music.Types.MusicItem))
         Member of Nokia.Music.MusicClient
    Summary:
    Searches MixRadio
    
    Parameters:
    searchTerm: Optional search term.
    category: Optional category.
    genreId: Optional genre id
    orderBy: The field to sort the items by.
    sortOrder: The sort order of the items.
    startIndex: The zero-based start index to fetch items from (e.g. to get the second page of 10 items, pass in 10).
    itemsPerPage: The number of items to fetch.
    requestId: Id of the request.
    cancellationToken: The cancellation token to cancel operation
    
    Return Values:
    A ListResponse containing MusicItems or an Error
    
    Remarks:
    A searchTerm or genreId should be supplied
    
    


    Tuesday, September 02, 2014 9:43 PM
  • where is the callback parameter?
    Tuesday, September 02, 2014 9:46 PM
  • What do you mean by a callback parameter? There is nothing related to that in the function signature you posted. For details on the Nokia API you'll be best off asking on the Nokia site where the API is provided.
    Tuesday, September 02, 2014 10:32 PM
    Moderator
  • Sorry the posting of the table got jumbled... It says..

    Table 2. Search Parameters

    Name          Description

    callback       The delegate to call once a response has been received.

    I'll try the Nokia site but to be honest, the Mods on here are much more attentive :)

    Assuming that the documentation is incorrect, is there a way to wrap the async call so that I can add a completed handler ?

    Wednesday, September 03, 2014 7:45 AM
  • I haven't used that API, but it looks like if you call SearchAsync it returns the value as a task. You can await it and not deal with an explicit callback. Alternatively, you can call Search (non-Async) and pass a callback as the first argument.

    --Rob

    Wednesday, September 03, 2014 7:59 AM
    Moderator