views:

20

answers:

1

Hey all,

I was wondering if someone could provide some advice on the following problem. We are currently developing a Silverlight 4 application based on RIA .NET Services. One of the screens in the application allows users to type in a search string and after 2 seconds of inactivity the request is submitted to our domain service. This is all handles nicely with Rx.

Now currently it is possible for a second search to be executed before the original has returned. Its also possible that the second request could return before the first.

Really I'm just trying to find out what patterns and approaches people are using to manage the correct response to the correct request.

Are you using some sort of operation identifier in your requests? Are you creating new instances of your domain services for each request? Is there away to tie the completed event of a request to the Rx observable monitoring the textchange event?

Any steer would be helpful really,

Dave

A: 

The simples way IMO is to have a subject for requests that you notify before any request is dispatched to WCF. Then rather than subscribing to observable created from the completed event subscribe to CompletedEventObservable.TakeUntil(RequestsSubject). This way you will never be notified with the response to the previous request.

PL