J
Jacob Anderson
Hello,
I have an MT application where one thread reads a file
and then subsequently creates TreeNode instances in a
TreeView. I get the familiar:
System.InvalidOperationException: The action being
performed on this control is being called from the wrong
thread. You must marshal to the correct thread using
Control.Invoke or Control.BeginInvoke to perform this
action.
exception when it attempts to run the following code:
view.Nodes.Add(node);
where view is my TreeView instance, and node is my new
TreeNode instance (created in a background thread).
Reading through the MSDN docs doesn't really give me any
insight on how to use Control.Invoke in this case. Does
anyone have any guidance in this case? I can't run it
all in the application thread since the file it reads is
VERY large.
Thanks
-- Jake
(e-mail address removed)
I have an MT application where one thread reads a file
and then subsequently creates TreeNode instances in a
TreeView. I get the familiar:
System.InvalidOperationException: The action being
performed on this control is being called from the wrong
thread. You must marshal to the correct thread using
Control.Invoke or Control.BeginInvoke to perform this
action.
exception when it attempts to run the following code:
view.Nodes.Add(node);
where view is my TreeView instance, and node is my new
TreeNode instance (created in a background thread).
Reading through the MSDN docs doesn't really give me any
insight on how to use Control.Invoke in this case. Does
anyone have any guidance in this case? I can't run it
all in the application thread since the file it reads is
VERY large.
Thanks
-- Jake
(e-mail address removed)