Can anyone point me to an example of calling a web service (not WCF) from C# using the new async/await syntax? Something like this:
public async Task<List<Widgets>> GetWidgetsAsync()
{
var proxy = new Service1();
var response = await proxy.GetWidgetsAsync();
return response.Result;
}
For a WCF service, when you add a reference and generate a proxy, there are options to generate either Task-based async methods or APM-based BeginXXX/EndXXX async methods.
I'm not sure about referencing the old-style XML Web service (asmx), but I think at least the second option should be there for it. In which case, you may wrap BeginXXX/EndXXX with Task.Factory.FromAsync, as described here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With