title: Process.Start in BackgroundWorker C#
body: <p>I'm having the worst time wrapping my head around threads/background processes.  My issues seem common enough to a certain point but I've yet to find a good example that meets my needs.</p>
  
  <p>The classic example goes like this:<br>
  My UI freezes when a certain long running task/process runs -I want to be able to at least move/minimize the UI.</p>
  
  <p>Classic replies include Threading and Task Factories and BackgroundWorker solutions.
  but no matter how I implement them I get poor results.</p>
  
  <p>In my program, I'm executing another application and waiting for it to finish. For the sake of simplicity let's say I'm doing it like so:</p>
  
  <pre><code>            Process p = Process.Start("notepad.exe somefile.txt");
              p.WaitForExit();
              //read somefile.txt
  </code></pre>
  
  <p>Clearly my application UI would hang while <code>WaitForExit()</code> grinds away waiting for me to close notepad.</p>
  
  <p>I've attempted a number of suggested means around this but I get painted into one of two corners:</p>
  
  <ol>
  <li>My interface still hangs, then reads somefile.txt just fine when I close notepad.</li>
  <li>The Process (Notepad) runs fine but my application reads somefile.txt immediately before I have closed notepad (So I guess it's running asynchronously) </li>
  </ol>
  
  <p>Most examples I see involve counting to a high number -simple but not quite what I'm doing.  Firing off this "external" process complicates things a bit.</p>
  
  <p>Thanks for your time and consideration!!</p>