N
nondos
Hello i have problem with thread,
I have Form with listview and User control.
I need the User control to run thread that will clear the listview in the
main form.
the code work but it's not clearing the listview, i debug the code and i see
the line of clearing the listview execute and i don't get any error message.
if i call the test sub directly from the form not as thread it's work fine.
any idea what's wrong
Thanks
control code:
Imports System.Threading
Public Class UserControl1
Sub start()
Dim t As Thread = New Thread(AddressOf Me.test)
t.Start()
End Sub
Sub test()
Form1.ListView1.Clear()
End Sub
End Class
Form code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
ListView1.Items.Add("a")
ListView1.Items.Add("b")
UserControl11.start()
End Sub
End Class
I have Form with listview and User control.
I need the User control to run thread that will clear the listview in the
main form.
the code work but it's not clearing the listview, i debug the code and i see
the line of clearing the listview execute and i don't get any error message.
if i call the test sub directly from the form not as thread it's work fine.
any idea what's wrong
Thanks
control code:
Imports System.Threading
Public Class UserControl1
Sub start()
Dim t As Thread = New Thread(AddressOf Me.test)
t.Start()
End Sub
Sub test()
Form1.ListView1.Clear()
End Sub
End Class
Form code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
ListView1.Items.Add("a")
ListView1.Items.Add("b")
UserControl11.start()
End Sub
End Class