Threads sounds like the right thing, yes. I have tested a few ways of making threads.
This is the most promising:
Imports System.Threading
Private Sub Testbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Testbutton.Click
Dim nthread As Thread
For i As Integer = 1 To 10
nthread = New Thread(AddressOf Me.CreateThread)
nthread.Start()
Next
End Sub
Private Sub CreateThread()
Dim j As Integer
For j = 1 To 5
i = i.ToString
listbox_test.Items.Add(i)
i += 1
Thread.CurrentThread.Sleep(2000)
Next
End Sub
If I understand correctly, this code creates 5 threads. Each one adds 10 numbers in the listbox. In this case (10 x) 10, 20 , 30, 40 and 50. If I do something while it works the numbers sometimes changes.
When that went so well, I thought I could just replace the For loop with my own sql query and display a Messagebox with the number returned. That only resulted in a "MC have encountered an error and have to close. We are sorry...... Debug, Close."
Can you tell me what I'm doing wrong? This is the code I tried:
Imports System.Threading
Private Sub Testbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Testbutton.Click
Dim nthread As Thread
For i As Integer = 1 To 10
nthread = New Thread(AddressOf Me.CreateThread)
nthread.Start()
Next
End Sub
Private Sub CreateThread()
SQLquery = "SELECT COUNT(*) FROM Artist"
subGetDBInteger()
MessageBox.Show(varDBqueryInt)
End Sub
The connection are done in the sebGetDBInteger, and are working fine on it's own...