WCF RIA 服务中的服务器进展
使用耗时的 wcf ria 服务时,我可以将进度更新从服务器发送到客户端吗?
Can I send progress updates from the server to the client when using time consuming wcf ria services?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然可以。无论如何,这不是一个开箱即用的解决方案...我们都知道,我们从 Silverlight 进行的每个调用都是异步的,因此无论是否有待处理的请求,客户端都会继续响应。
也就是说,您可以使用 HttpPollingDuplex 并使用这种回调来通知您的客户端,或者您可以简单地定期轮询服务器来获取操作的当前状态。
请注意,保存状态的服务器变量最好存储在 ASP.NET Session 中,并最终在 lock 块中访问,因为您从一个线程写入它并从另一个线程读取它
希望这会有所帮助
Of course you can. It's not an out of the box solution anyway... All we know that every call that we make from Silverlight is async, so the client continue to respond regardless if there are pending requests.
That said, you can either make use of HttpPollingDuplex and use that sort of callback to notify your client or you can simply poll the server ar regular interval to obtain the current status of the operation.
Be aware that the server variable that holds the state should be ideally stored in ASP.NET Session and eventually accessed in a lock block cause you are writing it from a thread and reading it from another one
Hope this helps