Threading and Having a class update a form control Problem....
Posted on 2004-10-27
I have a function that is currently wrapped up in a Class so I can pass a
variable to it.
This function is going to be threaded out and I would like the class
function to be able to update a control on my form. (Treeview).
Is this possible and how do I do it?
Here is a simplisitc overview of what I am doing...
Public Class Form1
Public Sub Button1_Click
Public Sub GetDirs()
Dim dir As String
Dim i As Integer = 1
Dim dirs() As String = Directory.GetDirectories("P:\")
For Each dir In dirs
Dim t As System.Threading.Thread
dim oListView as new SubClass1
t = New System.Threading.Thread(AddressOf
oListView.sFolder = dir
'''' I thought by passing the Treeview1 control I could update
it in the class...
oListView.tView = TreeView1
i += 1
ProgressBar1.Value = 100 * (i / CLng(UBound(dirs)))
Public Class SubClass1
Public sFolder as string
public tView as treeview
public sub FileListToListView
'''' **** Here is where I want to update the Form1.treeview1 control