im trying to make a simple example in threading this error msg
can anyone help me to solve it ?
Cross-thread operation not valid: Control 'cmb1' accessed from a thread other than the thread it was created on.
Imports System.Threading Public Class Form1 Inherits System.Windows.Forms.Form Dim th1 As Thread Dim th2 As Thread Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load th1 = New Thread(AddressOf proc1) th2 = New Thread(AddressOf proc2) th1.Start() th2.Start() End Sub Sub proc1() Dim iCount As Integer For iCount = 1 To 10 cmb1.Items.Add(iCount) Next End Sub Sub proc2() Dim iCount As Integer For iCount = 11 To 20 cmb2.Items.Add(iCount) Next End Sub End Class
Edited by Reverend Jim: fixed formatting