Error when using invoke to update a listview

0

I have a thread that calls a method that does "Invoke" in the listview, but this method only works with one parameter, I need it to accept 3.

My method:

Private Sub Updatelv(ByVal usuarios As String, ByVal status As String, ByVal datahoraAtual As String)
    If Me.InvokeRequired Then
        Dim args() As String = {usuarios, status, datahoraAtual}

 ## Cabeçalhos ##Me.Invoke(New Action(Of String)(AddressOf Updatelv), args)
        Return
    End If
    Me.lstvDados.Items.Add(New ListViewItem(New String() {usuarios, status, datahoraAtual}))
End Sub
    
asked by anonymous 21.04.2017 / 17:09

1 answer

0

I got it :):

Private Delegate Sub ListViewAddItem_delegate(ByVal destinataio As String, ByVal status As String, ByVal hora As String)

Private Sub ListViewAddItem(ByVal destinataio As String, ByVal status As String, ByVal hora As String)
    If Me.lstvDados.InvokeRequired Then
        Dim d As New ListViewAddItem_delegate(AddressOf ListViewAddItem)
        Me.lstvDados.BeginInvoke(d, {destinataio, status, hora})
    Else
        Dim lvi As New ListViewItem(destinataio)
        lvi.SubItems.Add(status)
        lvi.SubItems.Add(hora)
        lstvDados.Items.AddRange(New ListViewItem() {lvi})
        lstvDados.Update()
    End If
End Sub
    
21.04.2017 / 20:37