I have a silverlight application that needs to use multiple WCF services. The endpoints (urls) of the services cannot be hardcoded inside the silverlight application or the configuration file. They must be queried from a Service Registry which is itself a WCF service. The problem is that I have to use an async call to query the service endpoint before I can create an instance of the real service proxy. I can't think of a good way to wait for the response or block calls to real service. What is the best way to use the Service Registry / Service Locator pattern from whichin a silverlight application?
var registry = new ServiceRegistryClient("http://localhost/ServiceRegistry.svc");
string url;
registry.GetServiceCompleted += (s, e) => url = e.Result;
registry.GetServiceAsync("MyService");
// now I want to create MyService, but I must wait somehow until url is returned
var myService = new MyServiceClient(url);
myService.DoSomethingAsync();