Hi,
I am trying to print the numbers in a listbox control using a thread,
but its giving an error "Cross-thread operation not valid".
Please help me to resolve this error.
Thanks
...........
VB.NET code:
Imports System.Threading.Thread
Public Class Form1
Inherits System.Windows.Forms.Form
Dim thread1 As System.Threading.Thread
Public Sub addItems()
Dim ii As Integer
Dim no As Integer
no = 2
' add numbers to listbox
For ii = 1 To 10
ListBox1.Items.Add(no)
no *= 2
Next ii
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
thread1 = New System.Threading.Thread(AddressOf Me.addItems)
thread1.IsBackground = True
thread1.Start()
End Sub
End Class