Hi!
First Post Here! Self-taught vb.net programmer here!
Thanks for this (old!) topic which is still very relevant!
I do have a problem adapting your example to my situation though.
I have made this ticket monitoring app that makes requests to a DB and puts the info into Datagridview object. Now I want to put the DB subroutines through another process, and your code achieives this. Where I have a problem is in updating the DGV...
The sub that is threaded make these call to the thread that will invoke:
As you can see I pass a string array into an rows.add to my DGV...Code:row = New String() {OdbcDr.GetValue(0).ToString(), OdbcDr.GetValue(9).ToString(), OdbcDr.GetValue(10).ToString(), OdbcDr.GetValue(1).ToString(), OdbcDr.GetValue(11).ToString(), OdbcDr.GetValue(2).ToString(), OdbcDr.GetValue(7).ToString(), OdbcDr.GetValue(4).ToString(), ONS & strHour} ThreadUpdateDGV(row)
And it works because when I debug I can see my values are passed correctly
here is part of the sub that use the Invoke:
I do think I incorrectly call the Invoke for the DVG but, for the life of me, I come up empty. Can you tell me what I do wrong?Code:Protected Sub ThreadUpdateDGV(ByVal myrow As String()) If dgvTickets.InvokeRequired Then dgvTickets.Rows.Clear() dgvTickets.Invoke(New Action(Of String())(AddressOf ThreadUpdateDGV), myrow) Else dgvTickets.Rows.Add(myrow) End If




Reply With Quote