public void loadBlockWeb(string id, string host, int port, List<TreeNode> parents) { Thread tempThread = new Thread(new ThreadStart(delegate() { try { if (!container.Connect(host, port, id)) { throw new Exception(); } BlockWebNode myWebNode = new BlockWebNode(container.GetPeer(id)); myWebNode.id = id; myWebNode.host = host; myWebNode.port = port; innerTree.Invoke(new MethodInvoker(delegate() { foreach (TreeNode node in parents) { myWebNode.Attach(node); } imgLoading.Visible = false; })); } catch (Exception exc) { imgLoading.Invoke(new MethodInvoker(delegate() { imgLoading.Visible = false; //if failed, detach treenodes from their parents foreach (TreeNode node in parents) { if (node.Parent == null) { node.TreeView.Nodes.Remove(node); } else { node.Parent.Nodes.Remove(node); } } MessageBox.Show("Error Connecting: " + exc.Message); })); } })); imgLoading.Visible = true; tempThread.Start(); }
private void AttachBlockWeb(BlockWebNode blockWebNode) { TreeNode node = innerTree.Nodes.Add(""); blockWebNode.Attach(node); }