so I'm trying the following:
Code:Private Sub cmdQuery_Click(sender As Object, e As EventArgs) Handles cmdQuery.Click sw.Restart() sw.Start() If txtQuery.Text <> "" Then If SQL.HasConnection = True Then Threading.ThreadPool.QueueUserWorkItem(AddressOf DoQry) End If ' End If End If End Sub Private Sub DoQry() SQL.RunQuery(txtQuery.Text) UpdateGrid() End Sub Private Sub UpdateGrid() If DGVData.InvokeRequired Then DGVData.Invoke(New action(AddressOf UpdateGrid)) Else DGVData.DataSource = SQL.SQLDataset.Tables(0) ETlbl.Text = sw.ElapsedMilliseconds End If End Sub
While records are streaming into my SQL Table, at >200 records/second, I invoke a SQL query against it : a simple "select * from Optionstream" , which takes about 7 seconds.
However now I get an error: " The connection was not closed, The connection's current state is open".
which is the Exception error from the Try-Catch in my Addstream sub in the SQL Class. see previous post.
Before I added the multi-threading this was not the case.
What am I doing wrong?




Reply With Quote