I have a Web API Odata service that I am working on. The controller supports async but I can't seem to find any good examples on how to load a DataGridView async while pulling data from the OData service. I did find this link which has me some what there but I don't know how to finish the rest because I currently have to convert the DataServiceQuery into a list or the DataSource fails. http://msdn.microsoft.com/en-us/library/dd756367(v=vs.110).aspx
My code is something like this.
Private Sub getDataButton_Click(sender As Object, e As EventArgs) Handles getDataButton.Click
' Define the delegate to callback into the process
Dim callback As AsyncCallback = AddressOf OnLogsQueryComplete
' Define the query to execute asynchronously that returns
' all customers with their respective orders.
Dim query As DataServiceQuery(Of LogServiceReference.Log) = (From log In context.Logs
Select log)
' Begin query execution, supplying a method to handle the response
' and the original query object to maintain state in the callback.
DataGridView1.DataSource = query.BeginExecute(callback, query)
End Sub
Private Function OnLogsQueryComplete(ByVal result As IAsyncResult) As List(Of LogServiceReference.Log)
' Get the original query from the result.
Dim query As DataServiceQuery(Of LogServiceReference.Log) = _
CType(result.AsyncState, DataServiceQuery(Of LogServiceReference.Log))
Return query.EndExecute(result).ToList()
End Function
I can read / code either C# or VB, so if you have examples of either I am all ears...