in my Windows Phone 8 application, I have a LoadData() method in my file MainViewModel.cs.
This method load data from a WCF service with entity framework...
Then, in my pages, I call LoadData()
The LoadData() method :
public void LoadData()
{
client.GetMoviesCompleted += new EventHandler<ServiceReference1.GetMoviesCompletedEventArgs>(client_GetMoviesCompleted);
client.GetMoviesAsync();
client.GetTheatersCompleted += new EventHandler<ServiceReference1.GetTheatersCompletedEventArgs>(client_GetTheatersCompleted);
client.GetTheatersAsync();
this.IsDataLoaded = true;
}
With the methods :
private void client_GetMoviesCompleted(object sender, ServiceReference1.GetMoviesCompletedEventArgs e)
{
Movies = e.Result;
}
private void client_GetTheatersCompleted(object sender, ServiceReference1.GetTheatersCompletedEventArgs e)
{
Theaters = e.Result;
}
Then in my pages :
App.ViewModel.LoadData();
The problem is that it doesn't wait until the data is loaded.
Can you help me to use Async/Await the LoadData() method to wait until the data is loaded ?
Thanks