Hi
Ive got an app that holds a list of site we have, At each site there are a few devices.
The idea is when they click on a site all the details for the site are loaded and then a second thread sits and pings each device to see if its live. Im trying to do this in a seperate thread so if they click another site while its still pinging them it doesn't wait before it switches site.
This all seems to be workling fine except if you click through the sites quickly, when you do that it will eventually come up withIve been struggling to work out how to fix this so any help would be great{"Collection was modified; enumeration operation might not execute."}
the error flags up on the "Next" line in "ThreadedPing"
Thread stuff
Code:Public Sub ThreadedPing(ByVal dt As DataTable) Try Dim dr As DataRow For Each dr In dt.Rows dr("Ping") = PingaLing(dr("DeviceIP")) Next frmMain.lstS1AttDev.DataSource = dt frmMain.lstS1AttDev.Splits(0).DisplayColumns(0).Width = frmMain.lstS1AttDev.Width / 4 frmMain.lstS1AttDev.Splits(0).DisplayColumns(1).Width = frmMain.lstS1AttDev.Width / 4 frmMain.lstS1AttDev.Splits(0).DisplayColumns(2).Width = frmMain.lstS1AttDev.Width / 5 frmMain.lstS1AttDev.Splits(0).DisplayColumns(3).Width = 0 frmMain.lstS1AttDev.Splits(0).DisplayColumns(4).Width = frmMain.lstS1AttDev.Width / 5 Catch abortException As ThreadAbortException Console.WriteLine(CType(abortException.ExceptionState, String)) End Try End Sub Public Function PingaLing(ByVal strIPAdd As String) As String Dim dtstart As Date dtstart = Now Try My.Computer.Network.Ping(strIPAdd) Dim runLength As Global.System.TimeSpan = Now.Subtract(dtstart) PingaLing = runLength.Milliseconds & " ms" Catch ex As Exception PingaLing = "Cannot Find Host!" End Try End Function


Reply With Quote
