title: insert many files into List Box with different Threads
body: <p>a build an application who take video files (avi, mpeg..) and convert to another format.</p>
  
  <p>my application has listbox that i add files into and i added the option to add directory so with <code>SafeFileEnumerator</code> class (i found it here) i am check directory root and received only the folders with permissions and of course all the files and than i want to add all the relevant files into my list box but i want to do it if threads in order to avoid mt GUI to freeze so i try to use BackgroundWorker and i think i need some help to finish it because in my case here it doesn't work properly:</p>
  
  <pre><code>private void btnAddDirettory_Click_1(object sender, EventArgs e)
  {
      string fileToAdd = string.Empty;
      BackgroundWorker backgroundWorker = null;
      DialogResult dialog = folderBrowserDialog1.ShowDialog();
      if (dialog == DialogResult.OK)
      {
          btnAddfiles.Enabled = false;
          btnAddDir.Enabled = false;
          btnPlay.Enabled = false;
          someClass myClass= new someClass ();
  
          foreach (string fileName in SafeFileEnumerator.EnumerateFiles(folderBrowserDialog1.SelectedPath, "*.*", SearchOption.AllDirectories))
          {
              backgroundWorker = new BackgroundWorker();
              backgroundWorker.WorkerReportsProgress = true;
              backgroundWorker.DoWork +=
              (s1, e1) =&gt;
              {
                  if (myClass.iAviFormat(fileName))
                  {
                      if (myClass.isCorrectFormat(fileName))
                      {
                          backgroundWorker.ReportProgress(0, fileName);
                          //listBoxFiles.Items.Add(fileName);
                      }
                      else if (!myClass.isCorrectFormat(fileName))
                      {
                          fileToAdd = myClass.getNewFileName(fileName);
                          backgroundWorker.ReportProgress(0, fileToAdd);
                      }
                  }
              };
          }
  
          backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
          (s1, e1) =&gt;
          {
              btnPlay.Enabled = true;
              btnClear.Enabled = true;
              btnAddfiles.Enabled = true;
              btnAddDir.Enabled = true;
          });
  
          backgroundWorker.ProgressChanged +=
           (s1, arguments) =&gt;
           {
               listBoxFiles.Items.Add(arguments.UserState);
           };
  
          backgroundWorker.RunWorkerAsync();
      }
  }
  </code></pre>