I have a silverlight application that went it starts up, it needs to read a config file that a webservice returns.
So, in my main page, I want something like this:
public MainPage()
{
InitializeComponent();
Config cfg = new Config();
XDocument config = cfg.getConfig();
//doing stuff with config here
...
}
The constructor for config calls readConfigAsnc and I have a method for the readcompleted that returns the xdocument. I want the readConfigCompleted called before execution continues in MainPage(). What is the best way to go about doing this?
The best way is to separate this out into two methods. Pass a function as a parameter of the getConfig, so like this:
Later, in your code,
Another option would be to use lambda expression if you want to retain your local variables: