|
-
Dec 10th, 2001, 02:50 PM
#1
Thread Starter
Hyperactive Member
TreeView problem
Every time I try to add a node to a tree view I get the following message:
Code:
Additional information: 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.
I have not threaded this project, my add method is being called from a private sub.
Any ideas??
Thanks!
-
Dec 11th, 2001, 12:29 AM
#2
Where is the code located?
A .Net control is private to the Form that it is placed so you can't add nodes in a Sub that doesn't belong to the Form.
-
Dec 11th, 2001, 05:56 AM
#3
Lively Member
This error message you get tipically when you call a method on a control from other than the UI thread. You said you don't write multi threaded code in that app, but there are scenarios when the runtime creates new threads implicitly for you, with Async Delegates for example. So first try to find out if that's the case, by getting the HashCode of the CurrentThread (C#: MessageBox.Show(Thread.CurrentThread.GetHashCode().ToString()); )
If this is the case you should use Invoke or BeginInvoke.
(BeginInvoke = Async and Invoke = Sync)
-
Dec 11th, 2001, 10:24 AM
#4
Thread Starter
Hyperactive Member
The code is in an event of another control, all on the same form. It did tell me I need to use the begin invoke method (Visual Basic) however, there are no examples on how do do that.
Thanks for the help!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|