慢速操作。在RIA服务域服务类 [英] Slow Operations In A RIA Services Domain Service Class
问题描述
市所有,
我使用Silverlight 3与RIA服务。我不知道我应该如何处理在域名服务类较慢的操作?我有一个操作,将采取一两分钟。我得到一个WCF超时一分钟后,当客户端等待来自服务器的响应。
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.
也许是另一种方法?是能够告诉域服务类来启动的操作,并且然后轮询服务器,每5秒,看它是否已完成。
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.
例如。
呼叫从客户端域名服务 - '开始运作(这将启动一个新的线程)
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
任何想法?
推荐答案
您可以有你的服务操作返回某种请求标识符,存储在一个静态成员(如字典相关联的请求结果和状态ID)上的您的域名服务。该服务将产生一个线程异步处理此请求(preventing周转超时)。静止构件是由它完成时该线程更新
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.
然后,您可以使用该标识符Silverlight的查询。领域服务的新实例将使用静态成员返回的状态和结果。
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.
这篇关于慢速操作。在RIA服务域服务类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!