title: My codes are true , but an error message stop my program
body: <p>I write a code for inserting files too sql database. When the program is working an error message stop working:
  This is the error message:</p>
  
  <p>"The CLR has been unable to transition from COM context 0x52dd08 to COM context 0x52de78 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations"</p>
  
  <p>Please help me What I should to do.
  And This is my code:</p>
  
  <pre><code>                    for (int i = 0; i &lt; c; i++)
                      {
                          progressBar1.Visible = true;
                          progressBar1.Maximum = c;
                          progressBar1.Minimum = 0;
                          progressBar1.Step = 1;
                          byte[] jalal = null;
                          FileInfo fi = new FileInfo(listBox1.Items[i].ToString());
                          FileStream fs = new FileStream(listBox1.Items[i].ToString(), FileMode.Open, FileAccess.Read);
                          BinaryReader br = new BinaryReader(fs);
                          long totalbytes = new FileInfo(listBox1.Items[i].ToString()).Length;
                          jalal = br.ReadBytes((Int32)totalbytes);
                          fs.Close();
                          fs.Dispose();
                          br.Close();
                          byte[] bytes = File.ReadAllBytes(listBox1.Items[i].ToString());
                          SqlParameter fileP = new SqlParameter("@file", SqlDbType.VarBinary);
                          fileP.Value = bytes;
                          SqlParameter name = new SqlParameter("@pname", SqlDbType.NVarChar);
                          name.Value = fi.Name;
                          SqlParameter add = new SqlParameter("@padd", SqlDbType.NVarChar);
                          add.Value = listBox1.Items[i].ToString();
                          SqlCommand myCommand = new SqlCommand();
                          myCommand.Parameters.Add(fileP);
                          myCommand.Parameters.Add(name);
                          myCommand.Parameters.Add(add);
                          SqlConnection conn = new SqlConnection(@"Data Source=.;Initial Catalog=pdf;Integrated Security=True");
                          if (conn.State != ConnectionState.Open)
                              conn.Open();
                          myCommand.Connection = conn;
                          myCommand.CommandText = "spPdfInsert";
                          myCommand.CommandType = CommandType.StoredProcedure;
                          progressBar1.PerformStep();
  
                          Thread.Sleep(50);
                          try
                          {
                              myCommand.ExecuteNonQuery();
  
                          }
                          catch
                          {
                              kh++;
                              eror += this.listBox1.Items[i].ToString() + "\r\n";
                          }
  
                          conn.Close();
                          cc++;
                      }
  </code></pre>