views:

569

answers:

2

I'm using ASMX web services in VB.Net in VS 2005. I am calling a function method on the web service that returns a true or false value. This works fine if I call the the web method synchronously, but if I want to call the method asynchronously, the function returns to a sub and there is no return value; therefore, I can't tell whether the result of call is true or false. Is there a way to make an asynchronous call and still get the true or false result (perhaps using the userState Object)?

For Example:

Dim MyResult as Boolean = MyService.GetResult(10)
Dim MyResult as Boolean = MyServer.GetResultAsync(10)

This doesn't work the compiler complains: "Expression Does Not Produce a Value"

A: 

You don't say what kind of application you're using, but take a look at How to: Implement an Event-Driven Asynchronous Web Service Client Using ASP.NET 2.0.

John Saunders
FYI, I'm calling the web service from a WinForms apps, not ASP.Net.
OneSource
Then look at the previous article before the one on ASP.NET.
John Saunders
Thanks John, just what I was looking for!
OneSource
A: 

In the proxy class that VS creates for you must exists something looking like BeginGetResult - this method returns interface IAsyncResult - with help of them you can detect when execution done. After it you will get a value.

Dewfy
`Begin*/End*` are no longer necessary in his situation, with the new event-driven model introduced in .NET 2.0.
John Saunders