I\'m trying to make the UI of a page in a WP7 application more responsive by putting the data loading portion into a background thread rather than running in the foreground
It's very easy ;)
// must be executed in background
foreach (Item item in Items)
{
EventWaitHandle Wait = new AutoResetEvent(false);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
_events.Add(_newItem);
Wait.Set();
});
// wait while item is added on UI
Wait.WaitOne();
}
// here all items are added
This approach you can use everywhere where you need synchronize background and UI thread execution