title: Progress Bar not available for zipfile? How to give feedback when program seems to hang
body: <p>I am fairly new to C# and coding in general so some of this might be going about things the wrong way. The program I wrote works and compresses the file as expected, but if the source is rather large, the program appears (to Windows) to hang. I feel like I should be using a <code>Thread</code> but I am not sure that will help.</p>
  
  <p>I would use a progress bar but the 'new' (.net 4.5) library for zipfile from <code>System.IO.Compression</code> which replaced
  <code>Ionic.Zip.ZipFile</code> does not have a method to report progress? Is there a way around this? Should I be using a <code>Thread</code>? or <code>DoWork</code>?</p>
  
  <p>The trouble is that the user and the system is not getting feedback on what the program is doing. </p>
  
  <p>I am not sure I am asking the question the right way.
  Below is the code that is working, but again, will appear to hang the system. </p>
  
  <pre><code>    private void beginBackup_Click(object sender, EventArgs e)
      {
          try
          {
              long timeTicks = DateTime.Now.Ticks;
              string zipName = "bak" + timeTicks + ".zip";
              MessageBox.Show("This Will take a bit, there is no status bar :(");
              ZipFile.CreateFromDirectory(Properties.Settings.Default.source,
                    Properties.Settings.Default.destination + "\\" + zipName);
              MessageBox.Show("Done!");
              this.Close();
          }
          catch (IOException err)
          {
              MessageBox.Show("Something went wrong" + System.Environment.NewLine
                  + "IOException source: {0}", err.Source);
          }
      }
  </code></pre>
  
  <p>The important line being:         </p>
  
  <pre><code>        `ZipFile.CreateFromDirectory(Properties.Settings.Default.source,
                Properties.Settings.Default.destination + "\\" + zipName);`
  </code></pre>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p><code>ZipFile.CreateFromDirectory()</code>is not walking the directory so there is nothing to increment? it would simply start and finish with no reporting. Unless I am mistaken?</p>
  
  <p>using this method here:</p>
  
  <pre><code>        while (!completed)
      {
          // your code here to do something
          for (int i = 1; i &lt;= 100; i++)
          {
              percentCompletedSoFar = i;
              var t = new Task(() =&gt; WriteToProgressFile(i));
              t.Start();
              await t;
              if (progress != null)
              {
                  progress.Report(percentCompletedSoFar);
              }
              completed = i == 100;
          }
      }
  </code></pre>
  
  <p>the code in the for loop would only run once, as the Zipfile woudl still hang the program, then the progress bar would immediately go from 0 to 100?</p>