Hi all
I have a procedure that populates a ListView, but it does a lot of work and it takes too much time to display all it's items (about 100-200 items). I want to use a thread to display the items as it's extracting data (real-time).
I posted a question earlier here, but using a ListView it's not working for me...
Code:Imports System.Threading Imports System.ComponentModel Public Class Form1 Dim li As ListViewItem = lv.Items.Add("") Dim myThread As System.Threading.Thread = New Thread(AddressOf Me.AddItems) Public Delegate Sub ItemAdder(ByVal Input As String) Dim objItemAdder As ItemAdder Public Sub AddItemsDelgate(ByVal ItemToAdd As String) li = lv.Items.Add("") li.Text = ItemToAdd End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load objItemAdder = New ItemAdder(AddressOf AddItemsDelgate) myThread.Start() End Sub Public Sub AddItems() Dim i As Int32 Dim n As Double = 1 Dim s As String = "" For i = 0 To 100 s = n.ToString Me.Invoke(objItemAdder, New Object() {s}) n *= 2 Thread.Sleep(100) Next End Sub End Class




Reply With Quote
