Reputation: 2553
Hi All I have WCF service which has OperationContract GetCustomer(); and OperationContract GetCustomerSetting(int customerId);
In silverlight m calling GetCustomer method on OnLoad method of silverlight page. and then calling GetCustomerSetting for each of customer on GetCustomerCompleted method.
if I have 10 customer having Id 1,2,3...10 how do i make sure GetCustomerSettingCompleted will get call synchoronously for customer id 1 then 2 and then 3.
Upvotes: 1
Views: 423
Reputation: 3275
You could extend your model to have an isBusy accessor. You'd set the isBusy to true when you call the WCF and false after the completion. When you see that the previous object's isBusy is no longer true, then you can fire the next one.
I like to do it this way so that I can bind the isBusy to an action on my view - like a Telerik grid view.
Upvotes: 0
Reputation: 9469
If order is so important then you should have a method that takes a list of customers as a parameter and returns only when all the customers are processed (even if the client calls this operation asynchronously).
Upvotes: 0
Reputation: 1786
have a look here Sequential Asynchronous Workflows in Silverlight using Coroutines and here Sequential Asynchronous Workflows Part 2: Simplified. This is a (in my opinion) nice approach how to handle multiple async calls in a sync way.
Upvotes: 0
Reputation: 4096
There is no way to make a WCF call synchronously. In your GetCustomerCompleted() function you will have the return value of the function in e.Result (where you should actually have the ID of your Customer).
In that function, just call the GetCustomerSettings() with the ID that is in the e.Results.
Upvotes: 1