高手请进,多线程加载数据的问题!!
使用多线程加载listview1数据时,窗体其他控件不可用,同样的方法加载Datagrid其他控件可以正常使用。
dim thr as new system.threading.threadstart(addressof aa)
dim th as new system.threading.thread(thr)
thr.start
Public Sub lvdata()
Dim cn1 As New SqlClient.SqlConnection
Dim adapter1 As New SqlClient.SqlDataAdapter
If cn1.State = ConnectionState.Closed Then
cn1.ConnectionString = "server=lewis;database=demo1;uid=sa;pwd="
cn1.Open()
End If
adapter1.SelectCommand = New SqlClient.SqlCommand
adapter1.SelectCommand.Connection = cn1
adapter1.SelectCommand.CommandType = CommandType.Text
adapter1.SelectCommand.CommandText = "select top 10000 * from tblbomdetails"
adapter1.Fill(ds1)
lv.Invoke(New bb(AddressOf aa), New Object() {})
End Sub
Private Delegate Sub bb()
Private Sub aa()
For i As Int16 = 0 To ds1.Tables(0).Rows.Count - 1
lv.Items.Add(ds1.Tables(0).Rows(i)(0).ToString)
Next
End Sub