Hi!

Mình sử dụng delegate để update dữ liệu cho control thì gặp lỗi này nhưng ko biết sửa sao cả
"Exception has been thrown by the target of an invocation."
code VB.net nên mọi người thông cảm , but cùng chung .net mà ^^"

Code:
Imports System.Threading
Imports System.ComponentModel
Imports System.Net

Public Class Form1

    Private colThread() As BackgroundWorker
    Private Shared MaxThread As Integer = 10

    Public Delegate Sub UpdateListView(ByVal url As myUrl)
    Public _update As New UpdateListView(AddressOf StateUrl)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        CreaterThread()
        AddLst()
        Start()

    End Sub

    Private Sub Start()
        'Duyệt qua DS các url
        For i As Integer = 0 To lstMain.Items.Count - 1
            Dim fileProcessed As Boolean = False
            Dim ItemUrl As New myUrl(i, lstMain.Items.Item(i).Text)

            While Not fileProcessed
                'Duyệt qua cac thread
                For threadNum As Integer = 0 To MaxThread - 1

                    If Not colThread(threadNum).IsBusy Then
                        'Thực hiện xử lý file
                        colThread(threadNum).RunWorkerAsync(ItemUrl)
                        fileProcessed = True
                        Exit For
                    End If
                Next
                'tiếp tục chờ tới lượt
                If (Not fileProcessed) Then
                    Thread.Sleep(50)
                End If
            End While
        Next

    End Sub
    'Add url vào lst
    Private Sub AddLst()
        lstMain.Items.Add(New ListViewItem(New String() {"http://msdn.microsoft.com", ""}))
        lstMain.Items.Add(New ListViewItem(New String() {"http://the-simple-programmer.blogspot.com", ""}))
        lstMain.Items.Add(New ListViewItem(New String() {"http://mp3.zing.vn", ""}))
        lstMain.Items.Add(New ListViewItem(New String() {"http://msdn.microsoft.com", ""}))
    End Sub
    'Lấy mã html
    Private Function getHtml(ByVal url As myUrl) As myUrl

        Try
            Dim wc As New WebClient()
            url.Content = wc.DownloadString(url.Url)
            url.Alive = True
        Catch

        End Try

        Return url
    End Function
    'Tạo 1 mamgr các thread
    Private Sub CreaterThread()
        ReDim colThread(MaxThread)

        For idThread As Integer = 0 To MaxThread - 1
            'Tạo thread thứ i
            colThread(idThread) = New BackgroundWorker()
            colThread(idThread).WorkerReportsProgress = True
            colThread(idThread).WorkerSupportsCancellation = True
            'Đăng ký sự kiện
            AddHandler colThread(idThread).DoWork, AddressOf Me.bWorker_DoWork
            AddHandler colThread(idThread).RunWorkerCompleted, AddressOf Me.bWorker_RunWorkerCompleted
            AddHandler colThread(idThread).ProgressChanged, AddressOf Me.bWorker_ProgressChanged
        Next
    End Sub
    'Hàm thread thực hiện
    Private Sub bWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
        'ép kiểu về myUrl
        Dim url As myUrl = CType(e.Argument, myUrl)
        e.Result = getHtml(url)
    End Sub

    'Thread xử lý sau khi chạy xong
    Private Sub bWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
        If e.Error IsNot Nothing Then
            MessageBox.Show(e.Error.Message, "Error")
        End If


        Dim result As myUrl = CType(e.Result, myUrl)
        MessageBox.Show(result.Url & result.Alive, "")

        'Update lstview từ các thread
        'ĐANG NGHI NGỜ ĐOẠN NÀY
        Me._update(result)
    End Sub
    'Xử lý progressChanged
    Private Sub bWorker_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs)

    End Sub

    'Hàm update cho lstview
    Private Sub StateUrl(ByVal url As myUrl)
        Dim item As ListViewItem = lstMain.Items.Item(url.Id)
        Dim check As String = "Died"

        If url.Alive Then
            check = "Alive"
        End If

        item.SubItems(1).Text = check
    End Sub

   
End Class

Public Class myUrl

    Private m_id As Integer
    Private m_url As String
    Private m_alive As Boolean = False
    Private m_content As String

    Public Sub New(ByVal id As Integer, ByVal url As String)
        m_id = id
        m_url = url
    End Sub
    Property Alive() As Boolean
        Get
            Return m_alive
        End Get
        Set(ByVal value As Boolean)
            m_alive = value
        End Set
    End Property

    Property Url() As String
        Get
            Return m_url
        End Get
        Set(ByVal value As String)
            m_url = value
        End Set
    End Property

    Public Property Content() As String
        Get
            Return m_content
        End Get
        Set(ByVal value As String)
            m_content = value
        End Set
    End Property

    Public ReadOnly Property Id() As Int32
        Get
            Return m_content
        End Get
    End Property
End Class