Multithread a treeview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LucasOschip
    New Member
    • Sep 2010
    • 4

    Multithread a treeview

    Code:
    Public Class HTML5
    Public DOMTree As New Windows.Forms.TreeView
    Public Sub AddDocumentNameNode(Byval Name As String)
    DOMTree.Nodes.Add(Name)
    End Sub
    
    Public Class Tags
    
    Public Class a
    Private WorkerThread as System.Threading.Thread
    Private _Path As String = ""
    Public Property Path As String
    Get
    Return _Path
    End Get
    Set(Byval value as string)
    _Path = value
    End Set
    
    Public Sub LookForHref()
    WorkerThread = New System.Threading.Thread(AddressOf DoLookForHrefWork)
    WorkerThread.Start()
    End Sub
    Private Sub DoLookForHrefWork()
    Dim HTML5 As New HTML5
    HTML5.AddDocumentNameNode(DocName)
    End Sub
    End Class
    End Class
    End Class
    Now, when I run this code, it throws this exception: Action being performed on this control is being called from the wrong thread. Marshal to the correct thread using Control.Invoke or Control.BeginIn voke to perform this action.
    If you can explain to me how to properly use the BeginInvoke or Invoke methods or explain how to fix this to get it to work. Thanks. :)
Working...