VB Async / not working with datatables data

I am having problems converting this method from C # to VB, it works flawlessly in C #:

private async void Test() { DataSet dt; var client = new xxxSoapClient(); dt = await client.ToDoAsync(); } 

I use Async / await in VS 2012, and in C # this is all fine, but when I try to do the same in VB, it returns an error indicating that system.void is not expected !!!

 Private Async Sub Test() Dim dt As DataTable Dim Client As New xxxSoapClient dt = Await Client.ToDoAsync() End Sub 

The web service just returns a simple datatable, someone's ideas?

+4
source share
1 answer

The WCF proxy generator before VS2012 generates *Async methods that return void and signal their completion using events. Starting with VS2012, the WCF proxy generator by default generates *Async methods that return Task<T> .

Try re-creating the proxy.

If this does not work, check your β€œadvanced” parameters for the asynchronous method creation style. There are three styles : asynchronous programming model (APM) uses Begin* / End* / IAsyncResult ; Event-Based Asynchronous Template (EAP) uses *Async / *Completed / AsyncCompletedEventArgs ; A task-based asynchronous template (TAP) uses *Async / Task .

TAP works naturally with async / await , so the one you want.

0
source

All Articles