title: Update text in StatusBar in wpf using C#
body: <p>I have a TextBox in StatusBar in wpf which I want to update.</p>
  <p>I have a list of files in ListBox. On each file I would be doing some operation by calling say method ProcessFile(). So whenever the file processing is completed I want to show that file's name in the StatusBar text.</p>
  <p>I have tried something like this:</p>
  <pre><code>private void button_Click(object sender, RoutedEventArgs e)
      {
          
          statusBar.Visibility = Visibility.Visible;
  
          DispatcherFrame frame = new DispatcherFrame();
          Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(TimeConsumingMethod), frame);
          Dispatcher.PushFrame(frame);
          statusBar.Visibility = Visibility.Collapsed;
      }
  
      public object TimeConsumingMethod(Object arg)
      {
          ((DispatcherFrame)arg).Continue = false;
          
          foreach (string fileName in destinationFilesList.Items)
          {
              txtStatus.Text = fileName.ToString();
              //Assume that each process takes some time to complete
              System.Threading.Thread.Sleep(1000);
          }
          return null;
      }
  </code></pre>
  <p>But I can only see the last file's name in the StatusBar. What's wrong with the code? How can I correct it?</p>