Silverlight中的异步调用

编程入门 行业动态 更新时间:2024-10-24 08:30:53
本文介绍了Silverlight中的异步调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨 我有一个正在使用WCF的Silverlight3应用程序.我正在从Silverlight应用程序递归调用wcf中定义的一项服务. 问题是-我在这里面临的问题是,在获得第一个调用的结果之前,它正在激活第二个调用.所以有时候我会得到第二个Call(对wcf的调用)的结果,因为会得到第一个Call的结果.我知道Silverlight仅支持同步通话.但是在这种情况下,我该如何处理程序流程. 详细信息如下:

Hi I have a Silverlight3 application whcih is using WCF. I am calling one service which is defined in the wcf from my silverlight application recursively. The problem is - here I am facing is that before getting the result of the first call, it is activating the second call. So some times I am getting the result of the second Call(call to wcf) befor getting the result of first call. I know that silverlight support only Sync call. But in this situation how I can handle the program flow. Here is the details:

Silverlight appln { //Recursive call while(i<3) { callWCFAsync() // //do some work-- Here I want to do some work based on the result of 1 call, then based on the result of 2 call, then based on the result of 3 call(otherwise it should invoke the second call(in second iteration),only after getting the result of first call)-- How I can achieve it....?? } } WCF { definition of callWCFAsync() { } }

请帮助我. 在此先感谢... :):)

Please help me on this. Thanks in Advance... :) :)

推荐答案

这很简单.仅当对第一个服务的调用返回时,才调用第二个服务.这是确保第二个开始在SL中的异步调用中开始执行时,第一个调用的结果可用的唯一方法. 祝你好运! This is very easy. Call the second service only when the call to the first service returns. This is the only way to guarantee you have the results for the first call available when the second one starts execution in asynchronous calls in SL. Best of luck!

我写了一篇关于这个的文章: 我如何优化Silverlight异步Web服务的使用量 [ ^ ] I wrote an article about this: How I Optimized my Silverlight Asynchronous Web Service Consumption[^]

更多推荐

Silverlight中的异步调用

本文发布于:2023-11-11 10:43:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578197.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Silverlight

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!