title: Tree view is not updating in background
body: <p>here it is the FULL source code : <a href="http://pastebin.com/mLaGwwi0" rel="nofollow">http://pastebin.com/mLaGwwi0</a>
  As you will notice , the thing is to scan directories and files and populate them in a tree view. I am using background worker (the same happens with Threads class) to do that in background, while updating treeview with nodes one by one.
  The thing is that it is not working in background and not updating the treeview. This is the part of code which is hanging the form :</p>
  
  <pre><code>public void ListDirectory(DirectoryInfo path)
  {
      treeView1.Nodes.Add(CreateDirectoryNode(path));
  }
  
  public void Addnode(DirectoryInfo dirinfo)
  {
      Invoke(new AddCDAnode(ListDirectory), new object[] { dirinfo });
  }
  
  private TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo)
  {
      var directoryNode = new TreeNode(directoryInfo.Name);
      foreach (var directory in directoryInfo.GetDirectories())
      {
          //Statustext = directory.FullName;
          directoryNode.Nodes.Add(CreateDirectoryNode(directory));
      }
      foreach (var file in directoryInfo.GetFiles())
      directoryNode.Nodes.Add(new TreeNode(file.Name));
      return directoryNode;
  }
  
  public delegate void AddCDAnode(DirectoryInfo dirinfo);
  
  private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  {
      DirectoryInfo dir = new DirectoryInfo(@"\\server\trabajos 2013\");
      Addnode(dir);
  }
  
  private void Form1_Load(object sender, EventArgs e)
  {
      //Start filling the TreeView on a separate thread
      backgroundWorker1.RunWorkerAsync();
  }
  </code></pre>
  
  <p>In full source code you will see commented code - that is from example and working in background without any troubles. So i think the problem is with my code of scanning directories.</p>
  
  <p>The solution is <a href="https://www.wetransfer.com/downloads/3081d2a00af8150c352723d3a88a5c9c20130911190759/623fb154a192e25fa4fa9a3a1f617a1220130911190759/f5e4c8" rel="nofollow">also available here</a>, if you want to download it.</p>