Silverlight的WCF代理异步而已? [英] Silverlight WCF Proxy async only?

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

问题描述

为什么做Silerlight生成WCF代理类(ES)只提供异步调用?

Why do the Silerlight-generated WCF proxy class(es) offer only async calls?

有,我并不真的需要(在一个BackgroundWorker为例)异步模式的情况下

There are cases where I don't really need the async pattern (for example in a BackgroundWorker)

编辑:有时候,我需要处理两个结果WCF调用。这本来是简单得多,如果我可以等待(该应用程序的业务允许)为呼吁结束,然后处理..但NOOOO ....异步! :P

EDIT : Sometimes I need to process the results of two WCF calls. It would have been much simpler if I could have waited (the business of the app allows that) for both calls to end and then process.. but noooo.... async! :P

推荐答案

有实际上是一个技术原因,你不能做到同步调用,从主线程浏览器,至少,这是浏览器调用所有插件在API调用在同一个线程,因此,如果SL是为阻止线程在等待网络回调,网络回调不会打通和应用程序会死锁。如果从不同的线程启动的这就是说,同步API将正常工作 - 也就是说,如果应用程序第一次做了QueueUserWorkItem下车浏览器线程 - 但我们认为这将是混乱提供同步选项,只有拥有它工作在某些时候。

There's actually a technical reason you can't do sync calls, at least from the 'main' browser thread, which is that the browser invokes all the plug-in API calls on the same thread, so if SL were to block that thread while waiting for the network callback, the network callback wouldn't get through and the app would deadlock. That said, the sync API would work fine if initiated from a different thread -- ie, if the application first does a QueueUserWorkItem to get off the browser thread -- but we felt it would be confusing to offer the sync option and have it only work some of the time.

这篇关于Silverlight的WCF代理异步而已?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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