0
我有以下功能:如何調用AddPath()?
public void AddPath(String full_path)
{
TreeView tree_view = TheTreeView;
String[] split_path;
TreeNodeCollection current_nodes;
if (tree_view == null)
return;
if (String.IsNullOrEmpty(full_path))
return;
split_path = full_path.Split(tree_view.PathSeparator.ToCharArray());
current_nodes = tree_view.Nodes;
for (Int32 i = 0; i < split_path.Length; i++)
{
TreeNode[] found_nodes = current_nodes.Find(split_path[i], false);
if (found_nodes.Length > 0)
{
current_nodes = found_nodes.First().Nodes;
}
else
{
TreeNode node;
node = new TreeNode();
node.Name = split_path[i]; // name is the same thing as key
node.Text = split_path[i];
current_nodes.Add(node);
current_nodes = node.Nodes;
}
}
}
我需要從一個單獨的線程中調用這個函數。我將如何做到這一點? 我知道如何調用TreeView.Nodes.Add(),但我該如何做到這一點? 0.o
-Swen
這是你需要什麼? http://stackoverflow.com/questions/505523/c-sharp-invoke-a-method-with-type-invokemember-in-a-separate-thread – AdamWhite