Note that there are some explanatory texts on larger screens.

plurals
  1. POVB 2010 - I get results at the end of a loop and not during it
    primarykey
    data
    text
    <p>I'm using VB 2010 Express. I have a loop that calls a function named "singlePing" which pings an IP Address. If the application succeeded to reach that IP it turns a certain label back-color into green, otherwise - red. (There's a label for each ip address)</p> <p>When I'm running my application it seems that my application is "stuck" (actually it runs that loop) and after a while it updates the back-color of ALL THE LABLES at once.</p> <p>Why it doesn't update each label at a time? It makes the "user" think that the application got stuck. Here's my code:</p> <pre><code> Private Sub btnActivateMonitor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnActivateMonitor.Click Dim xmldoc As New XmlDataDocument() Dim xmlnode As XmlNodeList Dim fs As New FileStream(acXmlFileName, FileMode.Open, FileAccess.Read) Dim i As Integer Dim name As String Dim lbl As String Dim ip As String xmldoc.Load(fs) xmlnode = xmldoc.GetElementsByTagName("Unit") For i = 0 To xmlnode.Count - 1 name = xmlnode(i).ChildNodes.Item(0).InnerText.Trim() lbl = xmlnode(i).ChildNodes.Item(1).InnerText.Trim() ip = xmlnode(i).ChildNodes.Item(2).InnerText.Trim() checkUnitStatus(name, lbl, ip) Next End Sub Sub checkUnitStatus(ByVal name As String, ByVal lbl As String, ByVal ip As String) rtbLog.Text = rtbLog.Text &amp; TimeValue(Now) &amp; " Checking ..." &amp; name &amp; "(" &amp; ip &amp; ") ..........." If sendPing(ip) Then Me.Controls(lbl).BackColor = Color.Green rtbLog.Text = rtbLog.Text &amp; "success" &amp; vbCrLf Else Me.Controls(lbl).BackColor = Color.Red rtbLog.Text = rtbLog.Text &amp; "Failed" &amp; vbCrLf End If End Sub '+-------------------------------------- '| Send Ping (ip) '+-------------------------------------- Function sendPing(ByVal ip As String) Dim reachable As Boolean = False Try reachable = My.Computer.Network.IsAvailable AndAlso _ My.Computer.Network.Ping(ip, 10000) Catch pingException As System.Net.NetworkInformation.PingException Catch genericNetworkException As System.Net.NetworkInformation.NetworkInformationException ' Fail silently and return false End Try Return reachable End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload