Q:

Windows Phone 7 - How to Update UI From while Loop?

How would I update the UI in my Windows Phone app from a while, foreach, for, etc loop? 

A:

Have you considered using additional thread for this?
public MainPage()
        {
            InitializeComponent();
            Thread thread = new Thread(() => ReadFile(/*params*/));
            thread.Start();
        }

        private void ReadFile(/*params*/)
        {   
            while(/*condition*/)
            {
                /* READ FILE */

                //send task to UI thread to add object to list box
                Dispatcher.BeginInvoke(() => listBox1.Items.Add("YOUR OBJECT"));
            }
        }

Long term action is happening in non-UI thread, what makes that UI thread doesn`t get frozen. In every loop iteration, non-UI Thread sends action via Dispatcher.BeginInvoke to UI thread to add new object to listbox.

