I have a Silverlight 4 application using RIA services. One of the RIA service methods does something similar to the following:
List<Foo> fooList = this.GetListOfFoo();
AnotherService aService = new AnotherService();
foreach (Foo foo in fooList)
{
aService.SomeMethodCompleted += this.methodCompleted;
aService.SomeMethodAsync(foo);
}
return fooList;
SomeMethodAsync then makes changes to foo, which is a reference type.
this.methodCompleted is called for each Foo, but the updates to the Foo instances are not seen by the Silverlight client. I'm guessing nothing automatically waits for all of the async calls to finish before the RIA service returns to the Silverlight client.
My question is: can I coordinate the completion of the async calls before returning to the Silverlight client? Or am I limited to making only synchronous calls in a RIA service?