RIA 服务域服务类中的缓慢操作

发布于 2024-08-21 11:51:06 字数 367 浏览 5 评论 0原文

大家好,

我正在使用 silverlight 3 和 RIA 服务。我想知道应该如何处理域服务类中的缓慢操作?我要做一个手术,需要几分钟的时间。当客户端等待服务器响应时,一分钟后我收到 WCF 超时。

也许还有另一种方法?可以告诉域服务类开始一项操作,然后每 5 秒轮询一次服务器以查看它是否完成。

我尝试实现这个,我遇到的问题是域服务类是我调用的每个域服务方法的新实例。它是无状态的,这意味着我无法让域服务通过我的操作启动一个线程,然后再检查它。

例如,

从客户端调用域服务 - '开始操作'(启动新线程)

从客户端调用域服务 - '操作完成' - 这不起作用,因为我正在调用域服务的新实例

有什么想法吗?

sHi All,

I am using silverlight 3 with RIA services. I was wondering how I should deal with slow operations in a domain services class? I have an operation that will take a couple of minutes. I get a WCF timeout after a minute while the client is waiting for a response from the server.

Another approach perhaps? Is is possible to tell the domain services class to start an operation, and then poll the server every 5 seconds to see if it is finished.

I tried implementing this and the problem I ran into is that the domain service class is a new instance for every domain service method I call. It is stateless meaning that I cannot make the domain service start a thread with my operation, and later come and check up on it.

E.g.

Call domain service from client - 'start operation' (which starts a new thread)

Call domain service from client - 'is operation done' - this doesn't work because I am calling a new instance of the domain service

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福还没到 2024-08-28 11:51:06

您可以让您的服务操作返回某种类型的请求标识符,存储在域服务上的静态成员中(例如,将 id 与请求结果和状态相关联的字典)。该服务将生成一个线程来异步处理该请求(防止 WCF 超时)。静态成员在线程完成时由线程更新。

然后,您可以使用标识符从 SilverLight 进行轮询。域服务的新实例将使用静态成员返回状态和结果。

You could have your service operation return some kind of request identifier, stored in a static member (e.g. a dictionary associating the id with the request result and status) on your domain service. The service would spawn a thread to handle this request asynchronously (preventing the WCF timeout). The static member is updated by the thread when it is finished.

Then, you can poll from SilverLight using the identifier. New instances of the domain service would use the static member to return the status and result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文