title: C# ProgressBar Freezing
body: <p>I'm trying to calculatethe md5 hash of a file and put it in a textBox, I also have a ProgressBar that should keep running while the hash if being calculated, I set the ProgressBar to Marquee, and the bar will run while I select a file but as soon as the hash calculation starts the bar freezes until it is done.
  Here is my code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Diagnostics;
  using System.Drawing;
  using System.IO;
  using System.Linq;
  using System.Security.Cryptography;
  using System.Text;
  using System.Text.RegularExpressions;
  using System.Threading;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  
  namespace Calcula_MD5_BAR
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              Stopwatch timer = new Stopwatch();
              var openFileDialog1 = new OpenFileDialog();
              progressBar1.Style = ProgressBarStyle.Marquee;
              progressBar1.MarqueeAnimationSpeed = 30;  
              if (openFileDialog1.ShowDialog() == DialogResult.OK)
              {      
                  timer.Start();
                  textBox1.Text = GetFileMD5Hash(openFileDialog1.FileName);
                  timer.Stop();
                  lblTime.Text = timer.Elapsed.ToString();
                  progressBar1.Style = ProgressBarStyle.Continuous;
                  progressBar1.Increment(100);
              }
              progressBar1.MarqueeAnimationSpeed = 0;
          }
  
          protected string GetFileMD5Hash(string nomeArquivo)
          {
              FileStream file = new FileStream(nomeArquivo, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
              MD5 md5 = new MD5CryptoServiceProvider();
              byte[] retVal = md5.ComputeHash(file);
              file.Close();
  
              StringBuilder sb = new StringBuilder();
              for (int i = 0; i &lt; retVal.Length; i++)
              {
                  sb.Append(retVal[i].ToString("x2"));
              }
              return sb.ToString();
          }
  
  
  
      }
  }
  </code></pre>