Hi
Im new with Threading and I have a Thread that Execute a Query "SELECT" When debuging the codes I've notice that on my DataReader it takes time to finish the Execution.
On My Button.Click event
Dim LoadQuery As New Thread(AddressOf LoadToListView)
LoadQuery.IsBackground = True
LoadQuery.Start()
Ok I've change From Textbox to Listview so that 400 records will be shown
My LoadToListView Sub
Using DataRead As SqlClient.qlDataReader = cmd.ExecuteReader
If InvokeRequired Then
Me.Invoke(New DelegateSub(AddressOf LoadToListView)
Else
If DataRead.HasRows Then
While DataRead.Read
ListView2.Items.Add(Trim(DataRead(0).ToString))
ListView2.Items(ListView2.Items.Count - 1).SubItems.Add(Trim(DataRead(1).ToString))
ListView2.Items(ListView2.Items.Count - 1).SubItems.Add(Trim(DataRead(2).ToString))
End While
Else
MsgBox("No Data found", MsgBoxStyle.Exclamation, Me.Text)
DataRead.Close()
Exit Sub
End If
End If
DataRead.Close()
End Using
1. It take 3-5 Mins for the DataReader to Execute the Command can anybody explain it to me?
2. The UI freeze even I've used threading, Do I need to use background worker or It's fine without it.
3. What are the factors that make the DataReader Reads fast ?
4. What makes it slow?
on my MS SQL the Query runs fine it only take 11Sec to Query 400 Records with 4 fields
Hope you can Enlighten me with Threadings