开发者

.Net Async WebService call

开发者 https://www.devze.com 2023-01-08 06:46 出处:网络
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 fro

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.


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


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消