views:

46

answers:

2

I know all about threading applications, but haven't done this over web services before. Rather than have the client manage various threads, I want to just fire an async method and get the result from a callback.

It looks straight forward enough - just call the async method in the proxy class generated by visual studio. BUT WAIT... there isn't anywhere for me to specify a call back.

MSDN and other sites tell me I should be using Begin[MethodName] and End[MethodName], but they don't appear to exist/been-generated, I do have the [MethodName]Async method which is good (see here), but it doesn't have an option to pass in a delegate/callback.

I also have (staticly) ServiceName.MethodNameEventHandler/Args available, but can't use it as it isn't part of the instantiated service.

What is going on? and how can I send/receive a call back from a web service. I have noticed all the googling I've done provides me with pretty old sites. Can anyone provide me with an example.

A: 

I believe when you generate the web services through VS that there is a checkbox if you want to create async methods. Maybe you forgot to check that and so your services don't have the begin and end methods?

Chad
Doesn't appear to exists - where on the add web references is this supposed to be - look at the last screen shot on this web page http://blogs.msdn.com/b/kaevans/archive/2008/03/18/where-the-heck-is-add-web-reference-in-visual-studio-2008.aspx
Mr Shoubs
IIRC, this is only on the Add Service Reference in VS2008+. You can, however, use Add Service Reference to a .asmx web-service.
Nate Bross
A: 

If you have [MethodName]Async methods, you should have [MethodName]Completed events, which you can subscribe to, and that will act as your callback.

In vb.net it should be something like this:

AddHandler yourWebProxyClassInstance.[MethodName]Completed, AddressOf YourMethod
Nate Bross
How can I do this in vb.net? do you have any pages? I do have access to these methods, but only the async method is an instance method.
Mr Shoubs
... AddHandler _svc.UploadPartCompleted, AddressOf x(object evnt)?
Mr Shoubs
yes, similar. You'll need to adjust the method signature to match that of the Completed event.
Nate Bross
Yup, done that - bit rusty on the vb.net syntax is slightly different to C#.
Mr Shoubs