locked
reading a function issue

    Question

  • Hi,

    I am trying to hack some code together from google in a win store app project.  NB I am just starting on store apps.

    How do I read the below function...i call it using the below code into a 'task' but am unsure how to read the results of taskk.

             Dim taskk As Task(Of IEnumerable(Of String))
            Dim k2 As IMobileServiceTable(Of Item) = App.tester3Client.GetTable(Of Item)()
            taskk = ReadingByColumn(k2, "test name2")

        Private Function ReadingByColumn(table As IMobileServiceTable(Of Item), namek As String) As Task(Of IEnumerable(Of String))
            Return table.Where(Function(i) i.LastNameK = namek).[Select](Function(i) i.LastNameK).ToEnumerableAsync()
        End Function

    Friday, April 18, 2014 9:29 PM

Answers

  • You call an asynchronous function which returns a Task with the Await keyword:

    Dim stringList as IEnumerable(OfString)
    stringList = Await ReadingByColumnAsync(k2,"test name2")

    The convention is that functions which return tasks should have names ending in "Async" so it's clear what they do.

    See Quickstart: Calling asynchronous APIs in  C# or Visual Basic for more detail.

    --Rob

    Saturday, April 19, 2014 12:29 AM
    Owner

All replies

  • You call an asynchronous function which returns a Task with the Await keyword:

    Dim stringList as IEnumerable(OfString)
    stringList = Await ReadingByColumnAsync(k2,"test name2")

    The convention is that functions which return tasks should have names ending in "Async" so it's clear what they do.

    See Quickstart: Calling asynchronous APIs in  C# or Visual Basic for more detail.

    --Rob

    Saturday, April 19, 2014 12:29 AM
    Owner
  • that was what I was missing...cheers for that.

    Saturday, April 19, 2014 10:10 AM