thuli
03-30-2004, 12:12 PM
Hi, I am new to this forum (all forums, actually). I have read several and found them helpful, but I couldn't find anything to help me with this problem. I am trying to create a thread and from within the thread, add a node to a treeview. But I get the following error:
-
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.
-
My code is:
-
Private Sub frmMain_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim t As New Threading.Thread(AddressOf Go)
t.Start()
t = Nothing
End Sub
Private Sub Go()
TreeView1.Nodes.Add("NodeInfo")
End Sub
-
I'm thinking I have to use delegates, but I cannot, for the life of me, figure it out. Any help would be appreciated. Thanks.
Jason Thuli
thuli@chartermi.net
-
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.
-
My code is:
-
Private Sub frmMain_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim t As New Threading.Thread(AddressOf Go)
t.Start()
t = Nothing
End Sub
Private Sub Go()
TreeView1.Nodes.Add("NodeInfo")
End Sub
-
I'm thinking I have to use delegates, but I cannot, for the life of me, figure it out. Any help would be appreciated. Thanks.
Jason Thuli
thuli@chartermi.net