private delegate void AddNodeDelegate(TreeNode parent, TreeNode node); private void AddNode(TreeNode parent, TreeNode node) { if (!treeView.InvokeRequired) { parent.Nodes.Add(node); parent.Expand(); } else { treeView.Invoke(new AddNodeDelegate(AddNode), new Object[] { parent, node }); } }