10 Rules for Building a Windows Phone App: Listing 3.
Changing the Loaded event to offload data.
- By Max Zilberman
- 02/01/2012
BackgroundWorker getDataWorker = null;
void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
getDataWorker = new BackgroundWorker();
getDataWorker.DoWork += GetData_DoWork;
getDataWorker.RunWorkerCompleted +=new
RunWorkerCompletedEventHandler(getDataWorker_RunWorkerCompleted);
getDataWorker.RunWorkerAsync();
}
private void GetData_DoWork(object sender, DoWorkEventArgs e)
{
// Here call to get data
Model.GetData();
}
About the Author
Max Zilberman is an architect evangelist at Microsoft on the Developer andPlatform Evangelism team and is available at [email protected].