views:

326

answers:

1

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?

+1  A: 

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.

Timores