title: Read .TXT into ListBox in realtime
body: <p>I am reading a large Txt document into a WPF app for some serious swap/replacemnt operations. The files are actually 3D STP models so they are fairly large, but im working with them as raw text for this project. The files are read into List to avoid having to open them multiple times, and to make comparisons easier.</p>
  
  <p>Anyway, I'm trying to get the listbox to scroll dynamically as lines are added to it, ala a console window so the user can see that something is happening since calculations can take a bit of time depending on filesize. I also added a progress bar to count away as the total line number is read through. </p>
  
  <p>Neither my progress bar, nor ListBox seem to update as work progresses though. The final output simply lands in the listbox completed, and the progress bar goes from 0-max at the same time.</p>
  
  <p>This is the gist of what I am doing, which is fairly simple:</p>
  
  <pre><code>   foreach (string Line in OriginalSTPFile.Lines)
     {
         string NewLine = EvaluateString(Line);  //string the modified to whatever here
         pBar.Value++;   //increment progressbar
  
         OutputWindow.Items.Add(NewLine);  //add line to the ListBox
     }
  </code></pre>
  
  <p>I just want the listbox an progress bar to update in realtime as progress changes. I tried using:</p>
  
  <pre><code>Dispatcher.BeginInvoke(new Action(() =&gt; OutputWindow.Items.Add(NewLine));
  </code></pre>
  
  <p>But got the same results. Do I need a more elaborate method of multithreading here? I assumed the first method would've worked since I wasn't generating any cross-thread exceptions either.</p>