异步调用WCF服务 [英] Calling WCF service asynchronously

查看:101
本文介绍了异步调用WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何异步调用WCF服务方法?这意味着我需要调用一个需要20秒的服务方法.我想调用该方法并让客户端执行其他一些任务,即,我不应该等待该方法完成.简而言之,浏览器中的进度条不应显示20秒钟.浏览器应允许我执行页面中的其他任务.

How to call WCF service method asynchronously? That means I need to call a service method which takes, let''s say e.g, 20 seconds. I want to call that method and let the client to do some other tasks i.e, I should not wait for the method to complete. In simple words, the progress bar in browser should not appear for 20 seconds. The browser should allow me to do other tasks in the page. How can I incorporate this?

推荐答案

生成代理类时,它将为您生成aysnc方法(假设您尚未关闭此行为).假设服务上有一个Add方法,则客户端将同时具有Add AddAsync 方法,以及一个 AddCompleted 需要一个 AddCompletedEventArgs 来处理响应的事件.


MSDN clickety 此处 [
When you generate the proxy classes it genrates aysnc methods for you (assuming you haven''t switched this behaviour off). Suppose you have an Add method on the service, the client will have both Add and AddAsync methods, and an AddCompleted event that takes a AddCompletedEventArgs to handle the response.


MSDN clickety here[^]


这篇关于异步调用WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆