Hi,
Ive been trying to learn how to pass data from one thread to another, i read the guides here on Tek-tips and used google, but i cant seem to understand it.
I can make a simple thread, but i cant get it to use the data in my UI.
I have a form with a listview and 2 buttons, the listview is set to details, and have 3 columns, I want the Backgroundprocess Thread to insert data into the listview.
Code :
Im hoping someone here could help me along the way and perhaps show me the code i need to add for this to work.
Ive been trying to learn how to pass data from one thread to another, i read the guides here on Tek-tips and used google, but i cant seem to understand it.
I can make a simple thread, but i cant get it to use the data in my UI.
I have a form with a listview and 2 buttons, the listview is set to details, and have 3 columns, I want the Backgroundprocess Thread to insert data into the listview.
Code :
Code:
Imports System.threading
Public Class Form1
Dim t As Thread
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
t = New Thread(AddressOf Me.BackgroundProcess)
t.Start()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub BackgroundProcess()
Dim i As Int32 = 1
Do Until i = 10
Dim item As ListViewItem = ListView1.Items.Add("Iterations: " & i)
item.SubItems.Add("Iterations: " & i)
item.SubItems.Add("Iterations: " & i)
i += 1
Loop
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
t.abort()
End Sub
End Class
Im hoping someone here could help me along the way and perhaps show me the code i need to add for this to work.