I finished up a windows SFTP client I was writing this week and have been testing it with data. During the testing I encountered an interesting problem with one of the windows controls; It turns out the TreeView control which contains TreeNode objects is re-initialized on each node addition. The re-initialization of the control each time causes a massive performance hit, which ultimately locks up the UI thread.
The solution was to hide the control, populate the nodes, and then show it, like so:
public FormConstructor()
{
TreeView myTreeView = new TreeView();
myTreeView.Fill();
}
private void Fill()
{
myTreeView.Hide();
myTreeView.Nodes = GetNodes();
myTreeView.Show();
}