I'm adding programatically some rows in a datagridview every certain time. I want to view in the datagridview the status of certain github repositories, such as if are online, how much commits are in the repos at certain time, etc.
So, when there is timeout, i clear the rows with DataGridView.Rows.Clear() and then i add again the repositories with the updated info.
My code is here:
Dim ok As Integer = 0
DataGridView1.Rows.Clear()
For Each r As RepoURL In _impControllerBpi.GetReposApi
DataGridView1.Rows.Add(DateTimeOffset.Now, "https://github.com/" + r.GetUsr + "/" + r.GetNomRep, "-", "-", "-")
Next
Dim counter = 1
For Each r As RepoURL In _impControllerBpi.GetReposApi
DataGridView1.Rows.Item(counter - 1).Cells.Item(0).Value = DateTimeOffset.Now
DataGridView1.Rows.Item(counter - 1).Cells.Item(2).Value = "Conectando con GitHub"
ok = Await _impController.getRepoGitHub(r, counter)
If ok = 1 Then
DataGridView1.Rows.Item(counter - 1).Cells.Item(0).Value = DateTimeOffset.Now
DataGridView1.Rows.Item(counter - 1).Cells.Item(2).Value = "Conectado"
Else
DataGridView1.Rows.Item(counter - 1).Cells.Item(0).Value = DateTimeOffset.Now
DataGridView1.Rows.Item(counter - 1).Cells.Item(2).Value = "Repositorio no disponible en GitHub"
End If
counter = counter + 1
Next
Dim wreturnCode As Integer = System.Threading.ThreadPool.QueueUserWorkItem(New System.Threading.WaitCallback(AddressOf RepeatAction), cancellation.Token)
ok = 0
All works fine without Clear()
. But when i clear the rows, in some iteration, when i add the first row, the system throws me a
System.NullReferenceException
Some help? Clear()
frees the memory allocated for the collection of rows?