Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB
Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim ip = "www.google.com"
        Dim timeout = 1000
        Dim sw = New Stopwatch()
        Try
            Dim ping As Long = -1
            sw.Start()
            If My.Computer.Network.Ping(ip, timeout) Then
                sw.Stop()
                ping = sw.ElapsedMilliseconds

            End If
            If ping < 0 Then
                Label2.Text = "Timed Out"
                Label2.BackColor = Color.Brown
                Label2.ForeColor = Color.White

            ElseIf ping < 200 Then
                Label2.Text = "Good Connection"
                Label2.BackColor = Color.Green
            Else
                Label2.Text = "Bad Connection"
                Label2.BackColor = Color.Red
            End If
        Catch ex As Exception

            Label2.Text = ex.Message
            Label2.BackColor = Color.Red
            Console.WriteLine(ex.ToString())
        End Try
    End Sub
End Class

VB
<pre lang="vb"><pre lang="vb"><pre lang="vb">
Posted
Comments
Dave Kreskowiak 5-Jan-15 19:02pm    
You're going to have to define exactly what you mean by "GUI lag". What are you doing in your GUI and what exactly happens, versus what you expect to happen?

I have resolved the issue, I ran into timer problems.
 
Share this answer
 
I fixed the lag that was coming from the timer in this code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900