c# - How do invoke AddPath()? -
i have following function:
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; (int32 = 0; < 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 same thing key node.text = split_path[i]; current_nodes.add(node); current_nodes = node.nodes; } } }
i need call function seperate thread. how this? know how how invoke treeview.nodes.add() how this? 0.o
-swen
if need invoke object in ui thread different 1 created ( case ) answer cant. better answer can calling in winform control.invoke, , in wpf dispatcher.invoke. in winform can investigate if calling invoke required, using this method. in general should separate asynchronous part part updating ui in order avoid messing code.
Comments
Post a Comment